C# 级联拆分器面板的MDI形式
我在主窗体中显示我的MDI窗口,但在拆分器面板的一部分中,如下所示:C# 级联拆分器面板的MDI形式,c#,winforms,mdi,C#,Winforms,Mdi,我在主窗体中显示我的MDI窗口,但在拆分器面板的一部分中,如下所示: Form2 f2= new Form2(); f2.MdiParent = this; f2.Parent = this.splitContainer2.Panel2; f2.Show(); this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade); 但问题是,如果我编写这样的代码,我就无法级联它们: Form2 f2= new F
Form2 f2= new Form2();
f2.MdiParent = this;
f2.Parent = this.splitContainer2.Panel2;
f2.Show();
this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);
但问题是,如果我编写这样的代码,我就无法级联它们:
Form2 f2= new Form2();
f2.MdiParent = this;
f2.Parent = this.splitContainer2.Panel2;
f2.Show();
this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);
“this”是父窗体。主要形式
我能把它们串起来吗
谢谢大家。您必须覆盖SplitContainer面板的布局引擎。微软有一个创建自定义布局引擎的好例子
private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) {
//LayoutMdi(MdiLayout.Cascade);
Rectangle bounding = this.splitContainer1.Panel1.DisplayRectangle;
Point nextFormLocation = bounding.Location;
foreach (Control c in this.splitContainer1.Panel1.Controls) {
if (!c.Visible) {
continue;
}
nextFormLocation.Offset(c.Margin.Left, c.Margin.Top);
c.Location = nextFormLocation;
c.BringToFront();
if (c.AutoSize) {
c.Size = c.GetPreferredSize(bounding.Size);
}
nextFormLocation.X = bounding.X + 20;
nextFormLocation.Y = bounding.Y + 20;
}
}
只需将上述代码添加到您的cascade按钮,您就可以获得cascade的基本知识 好的,谢谢。但我仍然不清楚如何使CaseCade工作:(嗯……我不能用代码回答,所以我要添加另一个答案