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");
}
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.
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.
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.
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.
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.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.