一、针对Form创建可停靠Form
(一)下载WeifenLuo.WinFormsUI.Docking.dll在解压到文件啊添加工具箱来
下载地址:http://sourceforge.net/projects/dockpanelsuite/
(二)新建两个窗体Form1和Form2
把Form1属性 ismdicontainer 设成true 即是所谓的多文档窗体。在拖入dockpanle控件会弹出错误提示,打开项目属性设置框架该framework4就行了。
(三)写代码
- Form2做为可停靠窗体要继承WeifenLuo.WinFormsUI.Docking命名空间下面一个类DockContent
- Form1中
From2 f2 = new Form2();
f2.Show(dockPanel1);
f2.DockTo(dockPanel1, DockStyle.Top);
二、针对另一个容器控件(如:panel)创建可停靠Form
(一)下载控件WeifenLuo.WinFormsUI.Docking.dll在解压到文件啊添加工具箱来
(二)设置属性DocumentStyle = DockingWindow;
dockPanel_Patient.DocumentStyle = WeifenLuo.WinFormsUI.Docking.DocumentStyle.DockingWindow;
(三)写代码
- Form2做为可停靠窗体要继承WeifenLuo.WinFormsUI.Docking命名空间下面一个类DockContent
- 另一个容器中(如:panel)
From2 f2 = new Form2();
f2.Show(dockPanel1);
f2.DockTo(dockPanel1, DockStyle.Top);
(四)DockState
public enum DockState
{
Unknown = 0,
/// <summary>
/// 悬浮
/// </summary>
Float = 1,
/// <summary>
/// 顶部窗体自动隐藏
/// </summary>
DockTopAutoHide = 2,
/// <summary>
/// 左停靠窗体自动隐藏
/// </summary>
DockLeftAutoHide = 3,
/// <summary>
/// 底部停靠窗体自动隐藏
/// </summary>
DockBottomAutoHide = 4,
/// <summary>
/// 右停靠窗体自动隐藏
/// </summary>
DockRightAutoHide = 5,
/// <summary>
/// 停靠窗体文档对象
/// </summary>
Document = 6,
/// <summary>
/// 顶部停靠
/// </summary>
DockTop = 7,
/// <summary>
/// 左停靠
/// </summary>
DockLeft = 8,
/// <summary>
/// 底部停靠
/// </summary>
DockBottom = 9,
/// <summary>
/// 右停靠
/// </summary>
DockRight = 10,
Hidden = 11
}