C#中怎样创建MDI子窗体?

新手,尽量说详细点,最好有截图
2025-02-03 03:54:56
推荐回答(4个)
回答(1):

先在主窗体中设置(isMdicontainer为true)
范例:
给主窗体中拉进一个botton;双击(写代码)
如下:
Form2 myForm2 = new Form2();
myForm2.MdiParent = this;
myForm2.Show();

myForm2是实例化子窗体的对象

嘿嘿 希望你看了以后能明白
我在给你说时已经在我机子上做过,能实现

回答(2):

在MDI主窗体的【属性】对话框中,将MDI主窗体的IsMdiContainer属性设为true,如下图

将Button控件从工具箱拖到窗体上,如下图

给当前项目添加windows窗体,命名Child,如下图

给Button添加Click事件,代码如下

private void button1_Click(object sender, EventArgs e)

 {

            Child c = new Child();

            c.MdiParent = this;

            c.Show();

}

运行结果如下图

回答(3):

将父窗体的 IsMidContainer 设为true
然后往父窗体里 添加 toolStrip1 控件
单击toolStrip1添加一个控件(button,lable 都可以.)
然后在这个控件的事件里面引用子窗体

//显示子窗体,参数为子窗体实例。
private void ShowMdiChild(Form childForm)
{
childForm.MdiParent = this;
childForm.Show();
}
//在事件里引用
private void CreatTL_Click(object sender, EventArgs e)
{
ShowMdiChild(new CreatUser());
}

回答(4):

新建项里不是有MDI父级那个选项码?
VS2005/2008