private frmMain m_frm=new frmMain();//----
m_frm.show();
//in frmMainprivate void button1_Click(object sender, System.EventArgs e)
{
this.Hide();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;  
}

解决方案 »

  1.   

    Form2 about = null;//保证about只有一个实例private void menuItem4_Click(object sender, System.EventArgs e)
    {

    if(about == null)//保证about只有一个实例
    {
    about = new Form2();

                      
    about = null; }

    }
      

  2.   

    HNU(為楚有材,於斯為盛!)  的办法,如果打开一次,做一点修改,比如改变上面的某个 textbox -> 关闭 -> 在打开,不能保存上一次的修改,因为对象已经释放了  about = null;
      

  3.   

    Private Shared m_vb6FormDefInstance As FrmMain    Public Shared Property DefInstance() As FrmMain
            Get
                If m_vb6FormDefInstance Is Nothing OrElse _
                           m_vb6FormDefInstance.IsDisposed Then   '判断窗体实例是否存在
                    m_vb6FormDefInstance = New FrmMain
                End If
                DefInstance = m_vb6FormDefInstance
            End Get
            Set(ByVal Value As FrmMain)
                m_vb6FormDefInstance = Value
            End Set
        End Property
    这是我在VB中看到的实现,是在要显示的窗体中增加一个静态属性,然后直接调用这个静态属性显示就可以了。我不知道如何在C#中转换。
      

  4.   

    if(frm==null)
    {
    frmMain frm=new frmMain();
    }
    frm.show();
      

  5.   

    If you open all these modeless dialog's from the same 'main' form, then you can use the OwnedForms property of that main form to maintain this list of opened dialogs. Below are some code snippets that suggest how you must go about this. Note that your dialog forms need to be able to turn off the ownership. This is done below by adding an Owner field to the dialog form. 
    private void button1_Click(object sender, System.EventArgs e) 
     

     
         foreach ( Form f in this.OwnedForms ) 
     
         { 
     
              if (f is Form2) 
     
              { 
     
                   f.Show(); 
     
                   f.Focus(); 
     
                   return; 
     
              } 
     
         } 
      
         //need a new one 
     
         Form2 f2 = new Form2(); 
     
         this.AddOwnedForm(f2); 
     
         f2.Owner = this; 
     
         f2.Show(); 
     

     
      

  6.   

    //code for form2 
     
    public class Form2 : System.Windows.Forms.Form 
     

     
         private System.Windows.Forms.Label label1; 
     
         public Form Owner; 
     
         ....... 
     
         ....... 
     
         private void Form2_Closing(object sender, System.ComponentModel.CancelEventArgs e) 
     
         { 
     
              Owner.RemoveOwnedForm(this); 
     
         } 
     
    }
     
      

  7.   

    ChildForm childForm=null;//ChildForm为子窗体类;
    foreach(Form form in this.MdiChild)
    {
      if(form is ChildForm)
      {
        childForm=(ChildForm)form;
        break;
      }
    }
    if(childForm==null)
    {
      childForm=new ChildForm();
      childForm.parent=this;
      childForm.show();
    }
    else
    {
      childForm.active();
    }
      

  8.   

    那就用private Form2 myForm=new Form2()吧,在用的地方就用myForm.Show()来显示.
      

  9.   

    一个最简单的方法:
    把frmMain frm
    放在方法外面,类开始的地方.
    在方法里面这么写:
    if(frm==null)
    {
      frm=new frmMain();
      frm.show();
    }
    else
    {
      frm.A....(焦点那个,我忘了!)=ture;
    }一切搞定!