August 8, 2004
Logically, since you are using the ShowDialog method, you can't
get back to the button or object to reopen the dialog again without
first closing the open one. If you have it in a button click event, you
would be creating a new instance of the dialog everytime you click
the button. Now if you were using the Show method, you could
check to see if it is open, if your design is a certain way.
You could evaluate the Form.Visible property and see if it is visible.
I do not know whether you want to see if it has been disposed of,
or just hidden from view. If it has been disposed of, you would not
know. This is where the design comes in. If you do not have any
code that disposes of the form then you can call the Show method
without showing multiple forms. If, however, the user closes the
window using the X button at the top right corner of the screen,
then you would not know. You could trap the form's closing event
and call E.Cancel = true and Me.Hide, so you can safely call the
form again with the same instance and solve this problem. Then
the user does not have to remember to click a button on the form
when closing the window. I hope that this leads you to your solution!
Joseph MCP
"John" wrote:
Hi
I am opening a dialog using;
frmdialog = New frmdialognew
frmdialog.ShowDialog()
Is there a way to see if this dialog is already open to avoid opening
multiple instances of it?
Thanks
Regards