在主窗体中打开子窗体,新建窗体实例并指定其父窗体为MDI窗体时, 怎样解能打开多个相同窗体的实例问题????

解决方案 »

  1.   

    if (ActiveMdiChild is Form1)               
                {
                    return;      
                } 
                else  
                {
                    if (this.ActiveMdiChild != null) 
                      {
                        this.ActiveMdiChild.Close(); 
                      }
                    Form1 F= new Form1();   
                      F.MdiParent = this;             
                    F.Show();
                }
      

  2.   

    但愿我对你的理解没有错,可以打开同一子窗体多个
    Form2 f2 = new Form2();
    f2.MainForm = this;
    f2.MdiParent = this;
    f2.Show();
      

  3.   


    Form2 f2 = new Form2();
    f2.MainForm = this;
    f2.MdiParent = this;
    f2.Show();
    Form2 f3 = new Form2();
    f3.MainForm = this;
    f3.MdiParent = this;
    f3.Show();f2,f3都是Form2的实例,这样不可以?但愿我没理解错
      

  4.   

    将这些窗体定义成主窗体的成员变量。
     在要show它前,判断是否为null,如果为null就new,不为null,只show