Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I haven't been able to retrieve this information when searching on the forum...

My question is simple :

 

How can I prevent my program of opening two instance of the same child form ?

 

thx

What I don't know keeps me excited...
  • Leaders
Posted

could you not use something like a boolean?

maybe Dim FrmLoaded as Boolean

then on start up the boolean = False and when you load the first instance of the child form the boolean = True ,

then if the boolean = true tell it not to be able to load a childform ( ie: if frmLoaded = True then exit sub , else frmChild = new form2 , frmChild.Show blabla )

  • *Gurus*
Posted
My suggestion would be to expand on dynamic_sysop's suggestion by making that boolean variable a static ("shared" in vb.net) member of the form class. Then in the form's constructor you could set it to true, and check it before creating a new instance of the class.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

There is no possibilities to seek throughtout all open forms and notice if one of them is already opened ?

 

Something like For each frm in forms blabla ?

What I don't know keeps me excited...
Posted
Well, there is with a MDI form, but I don't think there is with a regular application aside from using System.Diagnostics.Process.GetProcessesByName() and GetProcessById() methods.
Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

The Forms collection from VB6 is no longer available. As wyrd mentioned, an MDI form knows about it's children, but looping through them all is not the .NET way - I'd go with divil's and dynamic_sysop's suggestions.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • Leaders
Posted

i always like the blabla explanation lol.

the boolean has been a god send in vb6 for me so i carried it over and have used it for various instances in .net already.

anyway glad to have finally been of assistance to someone on here instead of me asking a question.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...