MDI Question

  • Thread starter Thread starter John Underwood
  • Start date Start date
J

John Underwood

Hi.. I have a MDI with three additional child forms.. They can be
form1, form2, and form3 for this example.. I understand how to open
these three forms from my MDI, that works fine.. What I can't figure
out is how to open form2 from form1, or form3 from form1, etc..
instead of only opening them from my MDI form. I'm trying to figure
out how to open the child forms from other child forms.. If anyone
could point me in the right direction i'd appreciate it....

Thanks, John Underwood
 
From a button click in Form1.

private void button1_Click(object sender, System.EventArgs e)
{
Form frm = new Form1();
frm.MdiParent = this.MdiParent;
frm.Show();
}

- Or we have created an Env class that has a static MdiParent property -

public class Env
{
static System.Windows.Forms.Form mdiParent;
public static System.Windows.Forms.Form MdiParent
{
get { return mdiParent; }
set { mdiParent = value; }
}
}

private void MDIForm_Load(object sender, System.EventArgs e)
{
Env.MdiParent = this;
}

// inside a child form
private void button1_Click(object sender, System.EventArgs e)
{
Form frm = new Form1();
frm.MdiParent = Env.MdiParent;
frm.Show();
}

// if it will always be a child...
private void Form1_Load(object sender, System.EventArgs e)
{
this.MdiParent = Env.MdiParent;
}


HTH;
Eric Cadwell
http://www.origincontrols.com
 
Back
Top