Using the Panel control implementation in C # to nest another form in one form
Showallpage sallpage = new Showallpage ();
Sallpage.formborderstyle = Formborderstyle.none;
Sallpage.dock = DockStyle.Fill;
Sallpage.toplevel = false;
This. MainPanel.Controls.Clear ();
This. MAINPANEL.CONTROLS.ADD (Sallpage);
Sallpage.show ();
Mainpanel The Panel control in the main form, showallpage the form in the panel to be displayed in the primary form.
--------------------------------------------------------------------------------------------------------------- -----------------------------------------------------
FormBorderStyle property to set the border style of a new form
Dock property gets or sets which border is docked to the parent box body and determines how to resize with the parent box body
These two properties can be added without
But in the simplest way, it is the use of MDI
First, the parent window wants to set the IsMdiContainer property to True. To implement the parent-child window of an MDI structure
Then change to the following code in the window jump:
Example: General jump: Form1 f=new Form ();
F.show ();
Switch
Form1 C = new Form1 ();
C.mdiparent = this;
C.show ();
However, sometimes you encounter a problem, that is, the subform will jump out of the parent form of the 0, 0 coordinates, so in the parent form if there is a menu bar, the subform will be obscured, then we will be in the subform Form_Load () plus a sentence to set its distance from the top edge of the form
This. Top = 100;
This completes the nesting of one form in another form
Using the Panel control implementation in C # to nest another form in one form