我有一个带有一个主窗口和两个浮动 DockContent 窗口的程序(使用 DockPanel-suite 库)。当我运行程序时,我可以将两个浮动窗口停靠在一起,成为一个带有两个“选项卡”的浮动窗口。我的问题是如何以编程方式做到这一点?
这是我的代码:
public Form1()
{
InitializeComponent();
dp.Dock = DockStyle.Fill;
Controls.Add(dp);
DockContent dc1 = new DockContent();
RichTextBox rt = new RichTextBox() { Dock = DockStyle.Fill };
dc1.CloseButton = false;
dc1.CloseButtonVisible = false;
dc1.Text = "DockContent 1";
dc1.Controls.Add(rt);
dc1.Show(dp, DockState.Float);
DockContent dc3 = new DockContent();
RichTextBox rt3 = new RichTextBox() { Dock = DockStyle.Fill };
dc3.CloseButton = false;
dc3.CloseButtonVisible = false;
dc3.Text = "DockContent 2";
dc3.Controls.Add(rt3);
dc3.Show(dp, DockState.Float);
DockContent dc2 = new DockContent();
RichTextBox rt2 = new RichTextBox() { Dock = DockStyle.Fill };
dc2.Controls.Add(rt2);
dc2.Show(dp, DockState.Document);
}