1、创建父窗体:将你的窗体的IsMDIContainer 属性设置为 true
2、创建子窗体:
protected void MDIChildNew_OnClick(object sender, System.EventArgs e){
Form2 newMDIChild = new Form2();
// Set the Parent Form of the Child window.
newMDIChild.MDIParent = this;
// Display the new form.
newMDIChild.Show();
}
其实你看看帮助会得到你想要的。
2、创建子窗体:
protected void MDIChildNew_OnClick(object sender, System.EventArgs e){
Form2 newMDIChild = new Form2();
// Set the Parent Form of the Child window.
newMDIChild.MDIParent = this;
// Display the new form.
newMDIChild.Show();
}
其实你看看帮助会得到你想要的。
有一章专门将winforms 挺详细的!!
MDI主窗口通过ActiveMdiChild和MdiChildren来和子窗口联系。子窗口通过MdiParent来和父窗口联系。
>>具体讲一讲如何用父窗体控制关闭子窗体
关闭活动的子窗口
this.ActiveMdiChild.Close();
关闭其他打开的子窗口,可以遍历MdiChildren
foreach(Form f in this.MdiChildren)
f.Close();>>以及子窗体如何改变父窗体的状态
得到父窗口(假设为Form1)
Form1 f = (Form1)this.MdiParent
然后就可以通过 f 来完成所有的功能。>>子窗体间如何相互调用
和上面的差不多,也是用那几个联系,必要的时候,要进行类型转换。总的思路就是先得到MDI父窗口,然后通过它来找子窗口。