求助C#一个小问题:如何设置MDI父子关系窗体,如有Form1和Form2,设置Form1为父窗,Form2为子窗,即当关闭From1时,同时也关闭Form2,用代码如何实现?谢谢!

解决方案 »

  1.   

    父窗体中,在添加子窗体时
    ChildForm newChild=new ChildForm();
    newChild.MdiParent=this;
    newChild.Show();
      

  2.   

    然后在父窗口的关闭里面写关闭所有MdiChild的部分——一个for循环就可以了。
      

  3.   

    父窗体中,在添加子窗体时
    ChildForm newChild=new ChildForm();
    newChild.MdiParent=this;
    newChild.Show();
    其中ChildForm不识别,是不是还需要using.....?命名空间
    不知道是什么命名空间?请教!
      

  4.   

    那个 ChildForm 指的就是你的 Form2