MDI主窗体中可以打开多个子窗体,假如这多个子窗体是两种类型的(一个类型假设叫ChildForm1,另一个类型假设叫ChildForm2),我们可以通过LayoutMdi对打开的所有子窗体进行排序,代码如下:
private int i = 1;
private void toolStripButton1_Click(object sender, EventArgs e)
{
var childForm1 = new ChildForm1 {MdiParent = this, TopLevel = false,Text = "第"+i+"个窗体"};
childForm1.Show();
i++;
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
var childForm2 = new ChildForm2 { MdiParent = this, TopLevel = false, Text = "第" + i + "个窗体" };
childForm2.Show();
i++;
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
//垂直平铺
this.LayoutMdi(MdiLayout.TileVertical);
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
//水平平铺
this.LayoutMdi(MdiLayout.TileHorizontal);
}
private void toolStripButton5_Click(object sender, EventArgs e)
{
//层叠
this.LayoutMdi(MdiLayout.Cascade);
}
现在有个需求,假如打开多个ChildForm1和ChildForm2窗体后进行界面排序,选择垂直平铺时,ChildForm1必须在ChildForm2的上面,当选择水平平铺时,ChildForm1必须在ChildForm2的左面,当选择层叠时最先打开的在最外层。大牛帮帮忙。
- 7 回答
- 0 关注
- 256 浏览
添加回答
举报
0/150
提交
取消