axnst2
asked on
Activating MDIChild form from another MDIChild form
Hi Experts,
I have and MDI UI and I need to be able to open an MDIChild form from another MDIChild form. How do I accomplish that?
Thanks,
axnst2
I have and MDI UI and I need to be able to open an MDIChild form from another MDIChild form. How do I accomplish that?
Thanks,
axnst2
ASKER
Sorry I it goes like this:
class MDIChild1 : Form
{
private void cmdButton_Click(object sender, EventArgs e)
{
Form form = new MDIChild2(this.MdiParent);
form.Show();
}
}
public partial class MDIChild2 : Form
{
public MDIChild2 (Form MDIParentForm)
{
InitializeComponent();
this.MdiParent = MDIParentForm;
}
}
}
class MDIChild1 : Form
{
private void cmdButton_Click(object sender, EventArgs e)
{
Form form = new MDIChild2(this.MdiParent);
form.Show();
}
}
public partial class MDIChild2 : Form
{
public MDIChild2 (Form MDIParentForm)
{
InitializeComponent();
this.MdiParent = MDIParentForm;
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So that it'll behave like the rest of my MDI forms.
Thanks, I tried what you suggested and it worked good. Is this second MDIchild form disposed of when the user closes it, or do I have to free up the resources myself?
Thanks, I tried what you suggested and it worked good. Is this second MDIchild form disposed of when the user closes it, or do I have to free up the resources myself?
It is disposed of automatically when the user closes it (or when the application exits). You don't need to do anything special to it...
ASKER
class MDIChild1 : Form
{
private void cmdButton_Click(object sender, EventArgs e)
{
Form form = new Monitor(this.MdiParent);
form.Show();
}
}
public partial class MDIChild2 : Form
{
public Monitor(Form MDIParentForm)
{
InitializeComponent();
this.MdiParent = MDIParentForm;
}
}
}
This works fine, but what I'd really like to do is to have a function in the MDIParent form that I could call to open a child form from any other child form!