Learn WinForm third-party interface WeiFenLuo.winFormsUI.Docking.dll

Source: Internet
Author: User

  1. There are several classes available in the control DockPanel, two are important, one is DockPanel, the other is dockcontent,
       DockPanel  dockcontent is inherited from the form class and is used to provide a floating window base class. That is to say: The Dockcontent object can be arbitrarily welt in the DockPanel object, floating, tab, and so on.

  2. Browse->weifenluo.winformsui.docking.dll, add Reference, reference.
  3. Toolbox, right-click Options->.net Components, browse->weifenluo.winformsui.docking.dll-> the toolbox appears dockpanel.
  4. Drag dockpanel onto form FORM1, set dock properties, I set: Fill. Form Properties Ismdicontainer:true.
  5. Modify the form in code to inherit from Dockcontent. public partial class Form2:dockcontent
  6. In the main form:
     Public Partial classform1:dockcontent {//child Form        PrivateFrmcustomer Frmcustomer =NewFrmcustomer (); PrivateB_employee employee =NewB_employee ();  PublicForm1 () {InitializeComponent (); Frmcustomer.show ( This. DockPanel1); Employee. Show ( This. DockPanel1); System.Threading.Thread.Sleep ( -); }        Private voidForm1_Load (Objectsender, EventArgs e) {Form2 frm=NewForm2 (); frm. Show ( This. DockPanel1); //form Form2 Add to left edge of main formfrm. Dockto ( This. Dockpanel1,dockstyle.left); }}

  7. Add a right-click event to the main form, set DockPanel Contentmenuscrip to drag Menuscrip, form to add
     /// <summary>        ///Close all Forms/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidMenu_window_closeall_click (Objectsender, EventArgs e)        {closealldocuments (); }         Public voidclosealldocuments () {if(dockpanel1.documentstyle==documentstyle.systemmdi) {foreach(Form forminchMdichildren) {form.                Close (); }            }                Else{idockcontent[] documents=Dockpanel1.documentstoarray (); foreach(Idockcontent contentinchdocuments) {content.                    Dockhandler.close (); }                }            }        /// <summary>        ///Close Other Forms/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidMenu_window_closeother_click (Objectsender, EventArgs e) {            if(Dockpanel1.documentstyle = =documentstyle.systemmdi) {Form Activemdi=Activemdichild; foreach(Form forminchMdichildren) {                    if(Form! =Activemdi) {form.                    Close (); }                }            }            Else             {                foreach(Idockcontent documentinchDockpanel1.documentstoarray ()) {                    if(!document. dockhandler.isactivated) {document.                    Dockhandler.close (); }                }            }        }        /// <summary>        ///Find Form/// </summary>        /// <param name= "text" ></param>        /// <returns></returns>        PrivateDockcontent Finddocument (stringtext) {            if(Dockpanel1.documentstyle = =documentstyle.systemmdi) {foreach(Form forminchMdichildren) {                    if(Form. Text = =text) {                        returnForm asdockcontent; }                }                return NULL; }            Else {                foreach(Dockcontent contentinchdockpanel1.documents) {if(content. dockhandler.tabtext==text) {                        returncontent; }                }                return NULL; }        }         PublicDockcontent Showcontent (stringcaption, Type formtype) {dockcontent frm=Finddocument (caption); if(frm==NULL)            {                //frm = Childwinmanagement.loadmdiform (Portal.gc.MainDialog, FormType) as dockcontent;} frm. Show ( This. DockPanel1); frm. BringToFront ();//bring the control to the front            returnfrm; }

Learn WinForm third-party interface WeiFenLuo.winFormsUI.Docking.dll

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.