简体   繁体   中英

c# Creating MDI Child of Form1 from Form2

I am attempting to instantiate an instance of From3 as a child of Form1 by clicking a button on Form2.

However, when using the following code in Form2:

Form3 PFForm = new Form3();
PFForm.MdiParent = Form1;
PFForm.Show(); 

... to instantiate Form3 as a child of Form1 I get the error:

"'Form1' is a type, which is not valid in the given context."

Is Form2 also a child of Form1?

If yes, then:

Form3 PFForm = new Form3();
PFForm.MdiParent = this.MdiParent;
PFForm.Show();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM