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