Child MDI force Parent MDI to open new child.
Is there a way that a child form in a MDIContainer can get the parent to open a new child?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Eric Brown2 pointsPosted Oct 18, 2010, 4:56 PM EDT
public partial class Form1 : Form
{
public Form initForm = new Child1();
public Form nextChildForm = new Child2();
private void Form1_Load(object sender, EventArgs e)
{
initForm.MdiParent = this;
initForm.Show();
nextChildForm.MdiParent = this;
}
}
In the Child1 form, i have a button to display the other child form, here is the code to perform that.
private void button1_Click(object sender, EventArgs e)
{
Form1 parent = (Form1)this.MdiParent; // Form1 needs to be the name of the parent form
parent.nextChildForm.Show(); // can perform on public items
}