One, display another window as a dialog box. Add the following code to a button click or other event within Form1. Form2 fm2 = new Form2 (); Fm2.showdialog (); Features: FM2 cannot perform other operations when Form1 is open. You can continue only if FM2 is closed. Close the window for This.close ();
Second, in the Form1 open Form2,form2 as part of the Form1 to display.
Private voidForm1_Load (Objectsender, EventArgs e)
{
var frm= NewForm2 ();
frm. TopLevel= false;
This. Panel1. Controls.Add (frm);
frm. Show ();
}
650) this.width=650; "src=" http://pic002.cnblogs.com/images/2011/1781/2011071913332112.jpg "alt=" Demo "width=" 339 " height= "340" style= "border:0px;"/>
Third, if there are three forms, FORM1,FORM2,FORM3, when Form2 click, let Form3, in the Form1 panel display line? How do you write the code?
In the Form2:
private void Button1_Click (object sender, EventArgs e)
{
var frm1 = new Form1 ();
Frm1. Show ();
Frm1. ShowForm (New FORM3 ());
}
In the Form1:
internal void ShowForm (Form frm)
{
frm. TopLevel = false;
THIS.PANEL1.CONTROLS.ADD (frm);
frm. Show ();
}
Of course, when you choose to open Form1 is your own decision, not necessarily in the Form2 button1_click
C # Implementation displays multiple other Windows/another window within the same window