WinForm

WinForm

库:DockPanelSuite

1.NuGet包管理=>安装DockPanelSuite

2.工具箱=>DockPanel Suite=>将DockPanel拖到主窗体(假设为Form1)上

3.设置DockPanel

  • Dock = Fill
  • DocumentStyle = DockingMdi

4.设置主窗体(Form1

  • IsMdiContainer = true

5.新建用于停靠的窗体(Form2

  • Form2要继承自 DockContent

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using WeifenLuo.WinFormsUI.Docking;namespace Test
    {public partial class Form2 : DockContent{public Form2(){InitializeComponent();}}
    }
    

6.在主窗体加载事件中创建Form2以显示

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace 设计窗体
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){Form2 f_DeviceManage  = new Form2();f_DeviceManage.Show(dockPanel1);//让Form2在dockPanel1中显示f_DeviceManage.DockTo(dockPanel1, DockStyle.Left);//让Form2显示在dockPanel1左边}}
}

7.设置Form2

  • DockAreas不包括Document,从而不能显示在中间(占领全部,就像Dock = Fill 一样)

发布者:admin,转转请注明出处:http://www.yc00.com/news/1697989258a833092.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信