Wednesday, April 2, 2008

To create MDI form in C# /for beginners/

Let's say there are three form named Form1, Form2 and Form3.

Form1 is parent and Form2, Form3 are children.

1. Set the property isMdiContainer of Form1 to true and set WindowState to Maximized.
2. Place button1, button2 on Form1 to call Form2 and Form3.
3. Then onclick events of buttons in Form1

private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2 MdiParent = this;
frm2.Show();
}

private void button12_Click(object sender, EventArgs e)
{
Form3 frm3 = new Form3();
frm3 MdiParent = this;
frm3.Show();
}

That's all...

0 comments: