标签:icon containe this 组件 ext ack system gem eal
DockPanel是从panel继承出来的, 用于提供可浮动的dock的子窗口进行浮动和dock的场所,
DockContent是从form类中继承出来的, 用于提供可浮动的窗口基类. 就是说: DockContent对象可以在DockPanel对象中任意贴边, 浮动, TAB化等.
public partial class Form1 : DockContent { //子窗体 private FrmCustomer frmCustomer = new FrmCustomer(); private b_employee employee = new b_employee (); public Form1() { InitializeComponent(); frmCustomer.Show(this.dockPanel1); employee.Show(this.dockPanel1); System.Threading.Thread.Sleep(50); } private void Form1_Load(object sender, EventArgs e) { Form2 frm = new Form2(); frm.Show(this.dockPanel1); //窗体Form2添加到主窗体左边缘 frm.DockTo(this.dockPanel1,DockStyle.Left); } }
/// <summary> /// 关闭所有窗体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menu_Window_CloseAll_Click(object sender, EventArgs e) { CloseAllDocuments(); } public void CloseAllDocuments() { if (dockPanel1.DocumentStyle==DocumentStyle.SystemMdi) { foreach (Form form in MdiChildren) { form.Close(); } } else { IDockContent[] documents=dockPanel1.DocumentsToArray(); foreach (IDockContent content in documents) { content.DockHandler.Close(); } } } /// <summary> /// 关闭其他窗体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menu_Window_CloseOther_Click(object sender, EventArgs e) { if (dockPanel1.DocumentStyle == DocumentStyle.SystemMdi) { Form activeMdi = ActiveMdiChild; foreach (Form form in MdiChildren) { if (form != activeMdi) { form.Close(); } } } else { foreach (IDockContent document in dockPanel1.DocumentsToArray()) { if (!document.DockHandler.IsActivated) { document.DockHandler.Close(); } } } } /// <summary> /// 找到窗体 /// </summary> /// <param name="text"></param> /// <returns></returns> private DockContent FindDocument(string text) { if (dockPanel1.DocumentStyle == DocumentStyle.SystemMdi) { foreach (Form form in MdiChildren) { if (form.Text == text) { return form as DockContent; } } return null; } else { foreach (DockContent content in dockPanel1.Documents) { if (content.DockHandler.TabText==text) { return content; } } return null; } } public DockContent ShowContent(string caption, Type formType) { DockContent frm = FindDocument(caption); if (frm==null) { // frm = ChildWinManagement.LoadMdiForm(Portal.gc.MainDialog, formType) as DockContent; } frm.Show(this.dockPanel1); frm.BringToFront();//将控件带到前面 return frm; }
学习winform第三方界面weiFenLuo.winFormsUI.Docking.dll
标签:icon containe this 组件 ext ack system gem eal
原文地址:http://www.cnblogs.com/step-city/p/6094557.html