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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Mdi bug ? 9
Detecting active forms 6
MDI Problem 3
MDI Webbrowser... 2
Question on MDIchild forms 6
Windows Forms application 2
MDI Parent/Child forms 2
Passing data between two open Forms (neither is MDI) 1

Back
Top