470,573 Members | 1,763 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

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?
Nov 16 '05 #1
8 5832
Try this

if(openFileDialog1.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:ut*************@tk2msftngp13.phx.gbl...
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?

Nov 16 '05 #2
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:ut*************@tk2msftngp13.phx.gbl...
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?

Nov 16 '05 #3
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:ut*************@tk2msftngp13.phx.gbl...
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?

Nov 16 '05 #4
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:%2****************@TK2MSFTNGP10.phx.gbl...
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:ut*************@tk2msftngp13.phx.gbl...
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?


Nov 16 '05 #5
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.

"Christopher Kimbell" <a@b.c> wrote in message
news:40********@news.broadpark.no...
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:%2****************@TK2MSFTNGP10.phx.gbl...
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:ut*************@tk2msftngp13.phx.gbl...
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?



Nov 16 '05 #6
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.DoEvents() 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:eb**************@TK2MSFTNGP11.phx.gbl...
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.

"Christopher Kimbell" <a@b.c> wrote in message
news:40********@news.broadpark.no...
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:%2****************@TK2MSFTNGP10.phx.gbl...
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:ut*************@tk2msftngp13.phx.gbl...
> 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?
>
>



Nov 16 '05 #7
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.ShowDialog();

Refresh method will invalidate the whole client area.

Shak.
(Houston)
"e-mid" <yy@ss.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
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.

"Christopher Kimbell" <a@b.c> wrote in message
news:40********@news.broadpark.no...
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:%2****************@TK2MSFTNGP10.phx.gbl...
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:ut*************@tk2msftngp13.phx.gbl...
> 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?
>
>



Nov 16 '05 #8
thnkz, it is ok now...
"Shakir Hussain" <sh**@nodomain.com> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
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.ShowDialog();

Refresh method will invalidate the whole client area.

Shak.
(Houston)
"e-mid" <yy@ss.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
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.

"Christopher Kimbell" <a@b.c> wrote in message
news:40********@news.broadpark.no...
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:%2****************@TK2MSFTNGP10.phx.gbl...
> 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:ut*************@tk2msftngp13.phx.gbl...
> > 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?
> >
> >
>
>



Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jody Gelowitz | last post: by
3 posts views Thread by bobrad | last post: by
4 posts views Thread by Nagachandra Sekhar Grandhi | last post: by
6 posts views Thread by barbara_dave | last post: by
3 posts views Thread by Martijn Mulder | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.