C # setting MDI child forms can only pop up one method

Source: Internet
Author: User

The official interpretation of the MDI (multiple document INTERFACE) in Windows programming is the so-called multi-document interface, which corresponds to a single document interface (SDI), which is Microsoft Corporation from Windows2. 0 The Microsoft Excel spreadsheet program was introduced, and the Excel spreadsheet user sometimes needed to manipulate multiple tables simultaneously, and MDI was a great convenience for such operations, resulting in an MDI program. Create a new Windowform program. Get a form as our parent form. Drag into a menustrip space. In creating a new form Frmchildren as our subform, the interface looks like this: its code looks like this: PublicForm1 () {InitializeComponent (); //set Form1 to MDI form, of course, in Form1 's IsMdiContainer property page you can set   This. IsMdiContainer =true;} The event code for opening the subform in MenuStrip is as follows:Private voidTsmiopenwindow_click (Objectsender, EventArgs e) {Frmchildren child= Frmchildren.getwindow ();//Calling MethodsChild. MdiParent = This;//set child's parent form to the current formChild .  Show (); }getwindow () Where is this method? Of course it's written in the Frmchildren subform . Public Partial classFrmchildren:form {PrivateFrmchildren ()//changed from public frmchildren to private Frmchildren{InitializeComponent (); }    StaticFrmchildren FC =NULL; Create a static object Public StaticFrmchildren GetWindow () {//when the subform is not open or has been released. You can create a new form      if(fc==NULL||FC. isdisposed) {FC=NewFrmchildren (); }      returnFC; }} The second method: This method is easy for the individual to find. Open the subform directly under MenuStrip The write is OKPrivate voidTsmiopenwindow_click (Objectsender, EventArgs e) { #regionMethod Two application collects an open form, which is looked up by an indexer, which is the Name property of the form//method Two. If there is no child hull named Frmchildren, the instantiation is created. There is no difference between the formal practice and the previous, but more judgment. if(application.openforms["Frmchildren"] ==NULL) {Frmchildren child=NewFrmchildren (); MdiParent= This; Show ();}Else//there is a child hull named Frmchildren, which is directly show (){application.openforms["Frmchildren"]. Show ();}#endregion}

C # setting MDI child forms can only pop up one method

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.