Use of the WinForm interface layout control WeifenLuo. WinFormsUI. Docking (1) and winform paging Control
Use of the WinForm interface layout control WeifenLuo. WinFormsUI. Docking
(1)
Prepared by: CC Dad
In the blog of Wu huacong, we can see the layout control "WeifenLuo. winFormsUI. docking ", found that it is indeed a very good open-source control, used by people have deep experience, the control is powerful, beautiful, no less than commercial controls. And the use of controls is relatively simple today, I want to share with you this great control. If you are interested, you can discuss and learn it together. Otherwise, you can skip it.
I. Reference Method:
1. Create a WinForm project. A WinForm form is generated by default.
2. Reference-> Add reference-> browse-> weiFenLuo. winFormsUI. Docking. dll.
3. Form attribute IsMdiContainer: True.
4. Right-click the Toolkit and choose items>. net components> browse> weiFenLuo. winFormsUI. Docking. dll> dockPanel in the Toolkit.
5. Drag the dockPanel to the form and set the Dock attribute. I set Fill.Note that the menu toolbar is added first and thenDockpanelOtherwise, the layout interface is not displayed completely.
The specific design interface is as follows:
Add a form on the left and design it as the outlookbar style. It is actually in a docked form, inherited from WeifenLuo. WinFormsUI. Docking. DockContent
2. Add two other controls to the interface design:(UtilityLibrary + IrisSkin2)
UtilityLibrary. dll can produce outlookbar effects.
IrisSkin2.dll introduces skin Control
3. The interface after the design is completed is as follows:
4. The other part is the code part:
1. frmmain. cs section:
Private string m_strConfigFile;
Private DeserializeDockContent m_deserializeDockContent;
Public frmMain ()
{
InitializeComponent ();
InitializeLeftBar ();
}
Private void InitializeLeftBar ()
{
M_deserializeDockContent = new DeserializeDockContent (GetContentFromPersistString );
FrmTemp = this;
M_strConfigFile = Path. Combine (Path. GetDirectoryName (Application. ExecutablePath), "DockPanel. config ");
M_deserializeDockContent = new DeserializeDockContent (GetContentFromPersistString );
}
Private IDockContent GetContentFromPersistString (string persistString)
{
If (persistString = typeof (frmLeftBar). ToString ())
{
Return frmLeftBar;
}
Else
{
// Other child forms that can be added
Return null;
}
}
2. Load the Main Window
Private void frmMain_Load (object sender, EventArgs e)
{
Globalcolor = System. Drawing. Color. FromArgb (Convert. ToInt32 (W1.LoadXmlFileValue ("config. xml", "Color", "UserColor ")));
Globalcolor2 = System. Drawing. Color. FromArgb (Convert. ToInt32 (W1.LoadXmlFileValue ("config. xml", "Color", "IMColor ")));
CreditControl = Convert. ToBoolean (C_BaseInfo.GetsysConf (). Tables [0]. Rows [0] ["CreditControl"]);
// Set the time and date
Tssl1.Text = "today's date:" + DateTime. Now. ToString ("yyyy-MM-dd ");
Tssl2.Text = "Logon Time:" + System. DateTime. Now. ToLongTimeString ();
TsslLoginUser. Text = "current user:" + "" + frmLogin. C_UserInfo.SysUser;
MenuStrip MS = (MenuStrip) this. Controls ["menuStrip1"];
ArrayList arr = new ArrayList ();
Dsright = C_BaseInfo.UserRight (frmLogin. C_UserInfo );
GetMenuAllName (arr, null, 0, MS); // call a recursive function
If (File. Exists (m_strConfigFile ))
{
DockPanel1.LoadFromXml (m_strConfigFile, m_deserializeDockContent );
}
FrmLeftBar.Show(this.doc kPanel1, DockState. DockLeft );
This.doc kPanel1.BackgroundImage = global: ECM. Properties. Resources. cable_16_92;
}
3. display the subwindow
Private ECM. Purchase. frmPO frmpo = null;
Private void mnuPO_Click (object sender, EventArgs e)
{
If (FindFormName ("frmPO") = null)
{
Frmpo = new ECM. Purchase. frmPO (this );
Frmpo. MdiParent = this;
Frmpo.Show(frmMain.frmTemp.doc kPanel1 );
Frmpo. Focus ();
}
Else
{
Form f = FindFormName ("frmPO") as Form;
F. Focus ();
}
}
The following are some technical documents about the control for your reference.
Http://www.cnblogs.com/wuhuacong/archive/2009/07/09/1520082.html
Http://www.cnblogs.com/luomingui/archive/2013/09/19/3329763.html
Join the technology sharing group !!!!