Implementation of the DotNetBar control's multi-Document Interface

Source: Internet
Author: User
Document directory
  • 1. Multi-Document Interface Design
  • 2. Multi-document interface code implementation

DotNetBar is a good DotNET control set. It turns out to be a DLL file and can make a very nice interface effect. Remember the versions earlier than 8.0, it seems a little troublesome to implement multi-document interfaces, although my Winform framework and WCF framework also provide such multi-document interfaces, they are all implemented through curve saving. With the gradual improvement of the DotNetBar control, the version has soared, and files have begun to be split using multiple files like DevExpress. At present, Versions later than 11.0 have a SuperTabControl control, which makes it easy to implement multi-document interfaces. This article describes how to use the SuperTabControl control to implement a multi-Document Interface for your reference.

1. Multi-Document Interface Design

The following is an interface design effect of the framework based on the DotNetBar control. It is organized in the Ribbon style mode and the multi-document interface is placed in the middle, so that the interface effect is more beautiful and reasonable.

In addition, to close the window on the Tab page, you can add a right-click menu, as shown below.

Set the properties of the control so that its close button persists and associate it with its right-click menu, as shown below.

This SuperTabControl supports several Tab styles, some of which look very good. Select your favorite style.

 

2. Multi-document interface code implementation

In the Form_Load event on the main interface, we can clear and initialize the default Tab page, as shown below.

Private void MainForm_Load (object sender, EventArgs e) {Init (); // Clear the default Tab NavTabControl. Tabs. Clear (); tool_ItemDetail_Click (null, null );}
Private void tool_ItemDetail_Click (object sender, EventArgs e) {SetMdiForm ("spare part information", typeof (FrmItemDetail ));}

From the code above, we can see that the core interface layout is the SetMdiForm function. Let's take a look at the specific implementation of this function. This function is used to create or display a multi-document page.

/// <Summary> /// create or display a multi-document page // </summary> /// <param name = "caption"> form title </param >/// <param name = "formType"> form type </param> public void SetMdiForm (string caption, type formType) {bool IsOpened = false; // traverses the existing Tab page. If yes, set it to selected to foreach (SuperTabItem tabitem in NavTabControl. tabs) {if (tabitem. name = caption) {NavTabControl. selectedTab = tabitem; IsOpened = true; break; }}// if no If (! IsOpened) {// to facilitate management, call the LoadMdiForm function to create a new form and use it as the child form of MDI // then assign it to the SuperTab control, create a SuperTabItem and display DevComponents. dotNetBar. office2007Form form = ChildWinManagement. loadMdiForm (Portal. gc. mainDialog, formType) as DevComponents. dotNetBar. office2007Form; SuperTabItem tabItem = NavTabControl. createTab (caption); tabItem. name = caption; tabItem. text = caption; form. formBorderStyle = FormBorderStyle. none; form. topLevel = false; form. visible = true; form. dock = DockStyle. fill; // tabItem. icon = form. icon; tabItem. attachedControl. controls. add (form); NavTabControl. selectedTab = tabItem ;}}

As mentioned above, right-click menu operations to disable other or all Tab pages. This implementation is as follows.

        private void ctx_Window_CloseAll_Click(object sender, EventArgs e)        {            CloseAllDocuments();        }        private void ctx_Window_CloseOther_Click(object sender, EventArgs e)        {            CloseOthers();        }
       public void CloseAllDocuments()        {            for (int i = NavTabControl.Tabs.Count - 1; i >= 0; i--)            {                SuperTabItem tabitem = NavTabControl.Tabs[i] as SuperTabItem;                if (tabitem != null)                {                    tabitem.Close();                }            }        }        public void CloseOthers()        {            if (ActiveMdiChild != null)            {                Type formType = ActiveMdiChild.GetType();                for (int i = NavTabControl.Tabs.Count - 1; i >= 0; i--)                {                    SuperTabItem tabitem = NavTabControl.Tabs[i] as SuperTabItem;                    if (tabitem != null && formType != tabitem.AttachedControl.Controls[0].GetType())                    {                        tabitem.Close();                    }                }            }        }

The final interface effect is as follows.

The multi-Document Interface of another permission management system interface is adjusted as follows.

In this way, the Supertab control is introduced, and the overall multi-document Tab interface is more convenient and beautiful.

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.