MDI Children

Cassio

Junior Contributor
Joined
Nov 30, 2002
Messages
276
Location
Rio de Janeiro
How can I know if a MDI Child is already openned? I want the user to click an icon on the MDIParent menu and if the MDIChild is already openned it just get the focus instead of opening another MDIChild.

Thanks.
 
There's no built in way to do this like there was in VB6 (or previous versions). You can define a form-level variable in your MDI parent form. When the user clicks the button, check if the variable is Nothing (or null in C#) then create the form and show it. If it's not Nothing, just show the form.

There are other options, like using a static method of the child form to have IT control the one an only one instance. It's the same concept, but you'd call the static method of the child class which would instantiate a static variable (if not already Nothing or null) and show it.

-nerseus
 
Thanks Nerseus.
I´m trying to do it, but i'm not getting it right. Could you give me a example?
Im having problems when I close the MDIChild, i cant make it open again.
 
Back
Top