Forms 2, 3, 4 ... a design that falls only within the scope of form 1 (the parent form) and can be displayed all---MDI form design
Create an object of the MenuStrip class in Form 1 (menu bar), set one of the click events to show Forms 2, 3, 4
Private void Display Subform Toolstripmenuitem_click (object sender, EventArgs e) {new Form2 (); F2. Show (); New Form3 (); F3. Show (); New Form4 (); F4. Show (); }
This is done just to show forms 2, 3, 4, and they are not limited to the range shown in Form 1.
Form 1 is defined first as a parent form, and the Form1 property IsMdiContainer is set to true. Then set the Form2, 3, 4 property mdiparent to Form1. The display of Forms 2, 3, and 4 is limited to the scope of form 1.
private void Show Subform Toolstripmenuitem_click (object sender, EventArgs e) {Form2 F2 = new Form2 (); F2. MdiParent = this ; F2. Show (); Form3 f3 = FORM3 (); F3. MdiParent = this ; F3. Show (); FORM4 f4 = FORM4 (); F4. MdiParent = this ; F4. Show (); }
Because this method is in class Form1, this is referring to the Form1 we want.
The MDI form has a method LayoutMDI () that controls how the subform is arranged, and the parameter is an enumeration type of mdilayout.
Private void transverse arrangement toolstripmenuitem_click (object sender, EventArgs e) { LayoutMDI ( mdilayout.tilehorizontal); } Private void longitudinal arrangement toolstripmenuitem_click (object sender, EventArgs e) { LayoutMDI ( mdilayout.tilevertical); }
. NET Learning 3rd season WinForm application MDI Form Design MenuStrip