Because the project to use a dockable, floating form, found on the internet, there is really such a component, and is open source, download found very useful. Although on the internet has been on this aspect of the article, but in order to facilitate the use of the vast number of netizens, I will write some key code here.
The first is to load the DLL, in your toolbox right click → select → browse → find weifenluo.winformsui.docking.dll→ ok, this time, in your toolbox will be one more control.
Next, you can drag and drop this control onto your form (FORM1) and set several common properties below
This.dockPanel1.Dock = DockStyle.Fill this.dockpanel1.documentstyle= weifenluo.winformsui.docking.documentstyle.dockingmdi;//to set the main form as an MDI form, the error is not correct. Several other values do not need to set the main form to MDI, and then the style is slightly different. this.dockpanel1.defaultfloatwindowsize//set the default size of a floating form//The above four properties set the subform first appears at the top, bottom, left, and right positions, the default size, if the value is less than 1, For example, 0.1, the size of the subform is 10% of the dockPanel1 size, if greater than 1, such as 300, the first display height or width of the subform is This.dockPanel1.DockBottomPortion This.dockPanel1.DockLeftPortion this.dockPanel1.DockRightPortion this.dockPanel1.DockTopPortion
Next, we'll create a new Form2 and do the following to modify public partial class Form2:form//To public partial class Form2:WeifenLuo.WinFormsUI.Docking.Do Ckcontent this. The tabtext//subform displays the title this. autohideportion//The default size of the current form when it floats, less than 1 o'clock a percentage of the size of the main form DOCKPANEL1, greater than the value of 1 o'clock for width or height this. showhint//where the form is displayed for the first time or when it is opened in the main form
Next, back to the main form.
Form2 f=new Form2 (); F.show (this. DOCKPANEL1);
Let's take a look at the effect ^_^.
Download connection
Once again, thank DockPanel's author, Mr. Luo.