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?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Eric BrownPosted Oct 18, 2010, 8:56 PM
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
}