1、项目中引用WeifenLuo.WinFormsUI.Docking.dll
2、新建三个form,form2,form3继承之WeifenLuo.WinFormsUI.Docking.DockContent
public partial class Form2 : WeifenLuo.WinFormsUI.Docking.DockContent
{
public Form2()
{
InitializeComponent();
}
}
2.1 如果需要某个页面始终不被关闭,则在此form的frmCloseing事件中添加如下代码
e.Cancel = true;
3、在form1中添加控件dockPanel1,在load中添加如下代码
private void Form1_Load(object sender, EventArgs e)
{
dockPanel1.DocumentStyle = WeifenLuo.WinFormsUI.Docking.DocumentStyle.DockingWindow; //这句必须要加上 //或者 dockPanel1.Parent = this;
Form2 frm = new Form2();
frm.Show(dockPanel1); //panel1);
Form3 frm3 = new Form3();
frm3.Show(dockPanel1); //panel1);
}
效果如下:
4、修改顶部颜色
dockPanelGradient2.EndColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(255)))), ((int)(((byte)(250)))));
dockPanelGradient2.StartColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(255)))), ((int)(((byte)(250)))));
..