Beginners question on WinForms

  • Thread starter Thread starter Mark Bakker
  • Start date Start date
M

Mark Bakker

Hi,

Yesterday i tried to make my first Vb.net Winform application and i
struggled with the following:

I build a form with a mainmenu. I made the form (form1) a mdi form.
Now i want to click on a menu item and then another form (form2) has
to open in de mdi container. All this was going good. But when i click
the menu item again the same form opens twice. And when i click again
a third form is openend. How can i achieve that only one instance of
the form2 is openend?

Can someone help me with this one?

Greetings,

Mark
 
Why not disable that menu item when the particular form is open, you could
enable it again when the form is closed. This would be the easier method to
deal with it. See if this could help.
 
Hi Mark,

One solution might be to keep a reference to Form2 in your MDI parent. If
the reference is null create a new Form2, otherwise just ignore the menuitem
event. You will then also need to set the reference to null when you
destroy Form2 or you won't be able to recreate it.

Happy coding!
Morten Wennevik [C# MVP]
 
Back
Top