Beginners question on WinForms

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
 
T

Tarakeshwar L

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.
 
M

Morten Wennevik

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]
 

Ask a Question

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.

Ask a Question

Top