Detect Subforms

  • Thread starter Thread starter John Bailo
  • Start date Start date
J

John Bailo

I have a main form that can launch several subforms.

Both the main form remains active when the subform is visible.

I want to prevent the user from launching multiple copies of the subform.

How can I do this?

Here's my code for launching one of the subforms:


frmMove Move = new frmMove(this,
treeView1.SelectedNode);

Move.Show();
Move.Activate();
Move.TopMost=true;
 
John Bailo said:
I have a main form that can launch several subforms.

Both the main form remains active when the subform is visible.

I want to prevent the user from launching multiple copies of the subform.

The subform should then be a field in the parent form. The paremt form
should only create a new subform when there isn't already one in existence.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
Tim said:
The subform should then be a field in the parent form. The paremt form
should only create a new subform when there isn't already one in existence.

Well, I'm probably doing it totally wrong, but here's what I ended up doing.

When I launch, I create a member refernce in the parent (this is not MDI):

if(Child==null)
frmChild Child = new frmChild(frmParent);


So, at that point frmParent.Child holds the reference to the child, and
I pass in a reference to the parent in the constructor.

Then in the child Dispose() method I put

frmParent.Child=null;

So, if the child form is open, it will not launch a new form...it will
only activate and bring the existing one to the foreground.
 
Back
Top