你把你的frmJys写成静态类,每次只实例化一次就行了。在CSDN中查查实例化一次有好多这方面的答案的

解决方案 »

  1.   

    foreach(control obj in this.pnBack.Controls)
    {
       if(obj.GetType()==typeof(frmJys))
       {
         return;
       }
    }frmJys frmJys = new frmJys();
    frmJys.TopLevel = false;
    frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
    frmJys.Show();
      

  2.   

    foreach(Control obj in this.pnBack.Controls)  //Control第一个字母大写
    {
       if(obj.GetType()==typeof(frmJys))
       {
           return;
       }
    }frmJys frmJys = new frmJys();
    frmJys.TopLevel = false;
    frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
    frmJys.Show();
      

  3.   

    这样做当然是每次都是新窗体了,你可以:
    Form newForm;
    foreach(Form from in this.MdiChildren)
    {
             if(from.Name == "")
             {
    newForm = from;
    break;
    }
    }
    if(null == newForm)
    {
    newForm = new Form();
    }
      

  4.   

    if(from.Name == "你窗体的类名")
      

  5.   

    ====frmJys====
    public static bool IsOpen=false;=============
    if(! frmJys.IsOpen)
    {
        frmJys frmJys = new frmJys();
        frmJys.TopLevel = false;
        frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
        frmJys.Show();
        frmJys.IsOpen=true;
    }
      

  6.   

    你的代码,每次的form都是新的,form变量的定义你不要放在这里地方.
    至于你想要的效果,住高楼上的朋友都解答的好