Using DockPanel to implement dockable, floating, multiple document forms __ Documents

Source: Internet
Author: User

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.

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.