mdi-setting a subform can only pop up a

Source: Internet
Author: User

Shortcomings, please correct me!

What is MDI: I mean, I don't know.

MDI (Multiple document Interface) is the so-called multi-document interface, which corresponds to the single Document Interface (SDI), which was introduced by Microsoft from Microsoft Excel spreadsheet program under Windows 2.0, An Excel spreadsheet user sometimes needs to manipulate multiple tables at the same time, and MDI is a great convenience for this type of operation, resulting in an MDI program. --The mother explains this.

Create a new Windowform program. Get a form as our parent form. Drag into a menustrip space. Create a new form Frmchildren as our Subform

The code is as follows

 Public Form1 ()        {            InitializeComponent ();             // set Form1 to MDI form, of course, in Form1 's IsMdiContainer property page you can set             This true ;        }

The event code for opening the subform in MenuStrip is as follows:

Private void Tsmiopenwindow_click (object  sender, EventArgs e)        {               = Frmchildren.getwindow ( ); // Calling Methods             This ;//Set child's parent form to the current form child            . 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:

I think it's very simple. Open the subform directly under MenuStrip the write is OK

private void Tsmiopenwindow_click (object sender, EventArgs e)
{

#region Method Two application collects an open form, looking for it with 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 = new Frmchildren ();
Child. MdiParent = this;
Child. Show ();
}
Else//has a child hull named Frmchildren, which is directly show ()
{
application.openforms["Frmchildren"]. Show ();
}

#endregion

}

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.