2
Answers

About MDI forms

Photo of Rudi Steelman

Rudi Steelman

13y
1.8k
1
Please help me on this.

I have 3 forms on my project.

form1 is mdi controler
form2 and form3 is mdi child

the first question is how do i create form1 as parent and form2 and form3 as children.

and the second question

imagine form2 is open is the parent (form 1),and form 2 has a button if clicked it must open form3 in the parent form(form1).

please help me i'm stuck with this

i have no idea how to write a cord to this please some one help..........


thank u.

Answers (2)

0
Photo of Rudi Steelman
NA 11 7.1k 13y

first i thank u for ur kind attention

but

 no u didn't understood the problem. can i use the key word "this " when i'm in the form 2 then it will give me a error this is not a mdi container.

but i have to open the form3 inside form1(the parent form) throw the button on the form2 please help me.
0
Photo of Vulpes
NA 98.3k 1.5m 13y
First of all you need to set form1's IsMdiContainer property to true. You can do this from the Properties Box.

Then, when you create instances of form2 and form3 you need to set their MdiParent property to the instance of form1.

So, when you create an instance of form2 from form1:

Form2 f2 = new Form2();
f2.MdiParent = this; 
f2.Show();

and to create an indstance of form3 from a button click on form2:

private void button1_Click(object sender, EventArgs e)
{
    Form3 f3 = new Form3();
    f3.MdiParent = this.MdiParent;
    f3.Show();