openFileDialog

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • e-mid

    openFileDialog

    why does not openFileDialog have closed event?

    i want to do something; as soon as the dialog closes. is there a way to do
    this?


  • Shakir Hussain

    #2
    Re: openFileDialog

    Try this

    if(openFileDial og1.ShowDialog( ) == DialogResult.OK )
    {
    MessageBox.Show (""user has pressed Open button");
    }
    else
    {
    MessageBox.Show ("User has pressed cancel button or X button to
    close");
    }


    --
    Shak
    (Houston)




    "e-mid" <yy@ss.com> wrote in message
    news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...[color=blue]
    > why does not openFileDialog have closed event?
    >
    > i want to do something; as soon as the dialog closes. is there a way to do
    > this?
    >
    >[/color]


    Comment

    • Christopher Kimbell

      #3
      Re: openFileDialog

      One reason for there not being a close event is that the dialog can only be
      shown in modal mode,
      the code will wait until the ShowDialog() returns with a DialogResult value.
      You can use this value to determine an apropriate action based on how the
      Dialog was closed.

      Chris


      "e-mid" <yy@ss.com> wrote in message
      news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...[color=blue]
      > why does not openFileDialog have closed event?
      >
      > i want to do something; as soon as the dialog closes. is there a way to do
      > this?
      >
      >[/color]


      Comment

      • e-mid

        #4
        Re: openFileDialog

        in fact, i want to open another modal dialog according to file chosen. after
        i get dialogResult ; i keep filename. but i have to wait openfiledialog
        being closed to open a modal form.

        there seems no way to that?

        "e-mid" <yy@ss.com> wrote in message
        news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...[color=blue]
        > why does not openFileDialog have closed event?
        >
        > i want to do something; as soon as the dialog closes. is there a way to do
        > this?
        >
        >[/color]


        Comment

        • Christopher Kimbell

          #5
          Re: openFileDialog

          I' not quire sure what you want to achieve.
          Since the OpenFileDialog is modal, you can't get access to the selected
          filename before the dialog has closed.
          In the code posted by Shakir, replace the MessageBox code with some code
          that launches your other form.
          Before launching it, get whatever data you need from the OpenFileDialog
          object.


          Chris


          "e-mid" <yy@ss.com> wrote in message
          news:%23gVK8mCX EHA.1036@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > in fact, i want to open another modal dialog according to file chosen.[/color]
          after[color=blue]
          > i get dialogResult ; i keep filename. but i have to wait openfiledialog
          > being closed to open a modal form.
          >
          > there seems no way to that?
          >
          > "e-mid" <yy@ss.com> wrote in message
          > news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...[color=green]
          > > why does not openFileDialog have closed event?
          > >
          > > i want to do something; as soon as the dialog closes. is there a way to[/color][/color]
          do[color=blue][color=green]
          > > this?
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • e-mid

            #6
            Re: openFileDialog

            when i open my new modal form after i get dialog.ok result, openFileDialog
            window is open too. therefore i asked for openFileDialog closed event or
            some other way to do.

            "Christophe r Kimbell" <a@b.c> wrote in message
            news:40ded403$1 @news.broadpark .no...[color=blue]
            > I' not quire sure what you want to achieve.
            > Since the OpenFileDialog is modal, you can't get access to the selected
            > filename before the dialog has closed.
            > In the code posted by Shakir, replace the MessageBox code with some code
            > that launches your other form.
            > Before launching it, get whatever data you need from the OpenFileDialog
            > object.
            >
            >
            > Chris
            >
            >
            > "e-mid" <yy@ss.com> wrote in message
            > news:%23gVK8mCX EHA.1036@TK2MSF TNGP10.phx.gbl. ..[color=green]
            > > in fact, i want to open another modal dialog according to file chosen.[/color]
            > after[color=green]
            > > i get dialogResult ; i keep filename. but i have to wait[/color][/color]
            openfiledialog[color=blue][color=green]
            > > being closed to open a modal form.
            > >
            > > there seems no way to that?
            > >
            > > "e-mid" <yy@ss.com> wrote in message
            > > news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...[color=darkred]
            > > > why does not openFileDialog have closed event?
            > > >
            > > > i want to do something; as soon as the dialog closes. is there a way[/color][/color][/color]
            to[color=blue]
            > do[color=green][color=darkred]
            > > > this?
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • John Wood

              #7
              Re: openFileDialog

              The OpenFileDialog shows modally, and when OK or Cancel is clicked the
              dialog closes and you can do whatever you want. If you see that the dialog
              is still visible, then perhaps the screen has not yet had a chance to paint
              itself. You could get around this with an Application.DoE vents() call right
              after the ShowDialog function returns.

              --
              John Wood
              EMail: first name, dot, second name at priorganize.com


              "e-mid" <yy@ss.com> wrote in message
              news:ebXeWFHXEH A.3640@TK2MSFTN GP11.phx.gbl...[color=blue]
              > when i open my new modal form after i get dialog.ok result, openFileDialog
              > window is open too. therefore i asked for openFileDialog closed event or
              > some other way to do.
              >
              > "Christophe r Kimbell" <a@b.c> wrote in message
              > news:40ded403$1 @news.broadpark .no...[color=green]
              > > I' not quire sure what you want to achieve.
              > > Since the OpenFileDialog is modal, you can't get access to the selected
              > > filename before the dialog has closed.
              > > In the code posted by Shakir, replace the MessageBox code with some code
              > > that launches your other form.
              > > Before launching it, get whatever data you need from the OpenFileDialog
              > > object.
              > >
              > >
              > > Chris
              > >
              > >
              > > "e-mid" <yy@ss.com> wrote in message
              > > news:%23gVK8mCX EHA.1036@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
              > > > in fact, i want to open another modal dialog according to file chosen.[/color]
              > > after[color=darkred]
              > > > i get dialogResult ; i keep filename. but i have to wait[/color][/color]
              > openfiledialog[color=green][color=darkred]
              > > > being closed to open a modal form.
              > > >
              > > > there seems no way to that?
              > > >
              > > > "e-mid" <yy@ss.com> wrote in message
              > > > news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...
              > > > > why does not openFileDialog have closed event?
              > > > >
              > > > > i want to do something; as soon as the dialog closes. is there a way[/color][/color]
              > to[color=green]
              > > do[color=darkred]
              > > > > this?
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Shakir Hussain

                #8
                Re: openFileDialog

                e-mid,

                after clicking "Open" or "Cancel" button in the OpenFileDialog, it will
                close for sure.

                I believe, you were able to see the dialog box still(like it exists), which
                may be due to painting problem.

                After closing the OpenFileDialog call

                Form1.Refresh() ;
                Form2.ShowDialo g();

                Refresh method will invalidate the whole client area.

                Shak.
                (Houston)


                "e-mid" <yy@ss.com> wrote in message
                news:ebXeWFHXEH A.3640@TK2MSFTN GP11.phx.gbl...[color=blue]
                > when i open my new modal form after i get dialog.ok result, openFileDialog
                > window is open too. therefore i asked for openFileDialog closed event or
                > some other way to do.
                >
                > "Christophe r Kimbell" <a@b.c> wrote in message
                > news:40ded403$1 @news.broadpark .no...[color=green]
                > > I' not quire sure what you want to achieve.
                > > Since the OpenFileDialog is modal, you can't get access to the selected
                > > filename before the dialog has closed.
                > > In the code posted by Shakir, replace the MessageBox code with some code
                > > that launches your other form.
                > > Before launching it, get whatever data you need from the OpenFileDialog
                > > object.
                > >
                > >
                > > Chris
                > >
                > >
                > > "e-mid" <yy@ss.com> wrote in message
                > > news:%23gVK8mCX EHA.1036@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
                > > > in fact, i want to open another modal dialog according to file chosen.[/color]
                > > after[color=darkred]
                > > > i get dialogResult ; i keep filename. but i have to wait[/color][/color]
                > openfiledialog[color=green][color=darkred]
                > > > being closed to open a modal form.
                > > >
                > > > there seems no way to that?
                > > >
                > > > "e-mid" <yy@ss.com> wrote in message
                > > > news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...
                > > > > why does not openFileDialog have closed event?
                > > > >
                > > > > i want to do something; as soon as the dialog closes. is there a way[/color][/color]
                > to[color=green]
                > > do[color=darkred]
                > > > > this?
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • e-mid

                  #9
                  Re: openFileDialog

                  thnkz, it is ok now...


                  "Shakir Hussain" <shak@nodomain. com> wrote in message
                  news:utnsy1MXEH A.1888@TK2MSFTN GP11.phx.gbl...[color=blue]
                  > e-mid,
                  >
                  > after clicking "Open" or "Cancel" button in the OpenFileDialog, it will
                  > close for sure.
                  >
                  > I believe, you were able to see the dialog box still(like it exists),[/color]
                  which[color=blue]
                  > may be due to painting problem.
                  >
                  > After closing the OpenFileDialog call
                  >
                  > Form1.Refresh() ;
                  > Form2.ShowDialo g();
                  >
                  > Refresh method will invalidate the whole client area.
                  >
                  > Shak.
                  > (Houston)
                  >
                  >
                  > "e-mid" <yy@ss.com> wrote in message
                  > news:ebXeWFHXEH A.3640@TK2MSFTN GP11.phx.gbl...[color=green]
                  > > when i open my new modal form after i get dialog.ok result,[/color][/color]
                  openFileDialog[color=blue][color=green]
                  > > window is open too. therefore i asked for openFileDialog closed event[/color][/color]
                  or[color=blue][color=green]
                  > > some other way to do.
                  > >
                  > > "Christophe r Kimbell" <a@b.c> wrote in message
                  > > news:40ded403$1 @news.broadpark .no...[color=darkred]
                  > > > I' not quire sure what you want to achieve.
                  > > > Since the OpenFileDialog is modal, you can't get access to the[/color][/color][/color]
                  selected[color=blue][color=green][color=darkred]
                  > > > filename before the dialog has closed.
                  > > > In the code posted by Shakir, replace the MessageBox code with some[/color][/color][/color]
                  code[color=blue][color=green][color=darkred]
                  > > > that launches your other form.
                  > > > Before launching it, get whatever data you need from the[/color][/color][/color]
                  OpenFileDialog[color=blue][color=green][color=darkred]
                  > > > object.
                  > > >
                  > > >
                  > > > Chris
                  > > >
                  > > >
                  > > > "e-mid" <yy@ss.com> wrote in message
                  > > > news:%23gVK8mCX EHA.1036@TK2MSF TNGP10.phx.gbl. ..
                  > > > > in fact, i want to open another modal dialog according to file[/color][/color][/color]
                  chosen.[color=blue][color=green][color=darkred]
                  > > > after
                  > > > > i get dialogResult ; i keep filename. but i have to wait[/color]
                  > > openfiledialog[color=darkred]
                  > > > > being closed to open a modal form.
                  > > > >
                  > > > > there seems no way to that?
                  > > > >
                  > > > > "e-mid" <yy@ss.com> wrote in message
                  > > > > news:utMHpm8WEH A.644@tk2msftng p13.phx.gbl...
                  > > > > > why does not openFileDialog have closed event?
                  > > > > >
                  > > > > > i want to do something; as soon as the dialog closes. is there a[/color][/color][/color]
                  way[color=blue][color=green]
                  > > to[color=darkred]
                  > > > do
                  > > > > > this?
                  > > > > >
                  > > > > >
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  Working...