C # Implementation displays multiple other Windows/another window within the same window

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.