C#mdi窗体,其中有多个子窗体,我要如何只打开一个窗体呢?如:Form1,Form2,Form3为子窗体.怎么样我打开Form1时就把Form2和Form3关闭,打开Form2时就把Form1和Form3关闭..................

解决方案 »

  1.   

             foreach (Form f in this.MdiChildren)
                {
                    if (f.Name == "form2")
                    {
                        f.Close();
                    }
                }
    判断去吧。
      

  2.   

     
              //移除所有的子窗体
                foreach (Form frm in this.MdiChildren )
               {
                    frm.Close();
                //打开新子窗体
                Form f1 = new Form();
                f1.MdiParent = this;
                f1.Show();
               }