title: how to prevent my program to open the same window Form twice
body: <p>i am working on a project, i am creating a instance and opening a specific form in my program, like i use following code to open a form:</p>
  
  <pre><code>  frm2 cs = new frm2();
    cs.Show();
  </code></pre>
  
  <p>but the problem here is each time i click on the button it just open a new windows and the previous one is also opened, all i want to do here is when i click on button and that window is already open then it simply go to already opened windows except opening the new one.
  hope you guys understand my question and will help me doing it.</p>
  
  <h2>EDIT:</h2>
  
  <p>i tried this code : the code i wrote in frm2.cs file is:</p>
  
  <pre><code>   public partial class frm2 : Form
      {
  
         private static frm2 _form2 = null; 
  
          public frm2()
          {
              InitializeComponent();
          }
  
          public static frm2 Instance
          {
              get
              {
                  if (_form2 == null)
                  {
                      _form2 = new frm2();
                  }
                  return _form2;              
              }
          }
  </code></pre>
  
  <p>and in frmMain.cs file where i code to access the instance and open the project is :</p>
  
  <pre><code>private void addProductToolStripMenuItem_Click(object sender, EventArgs e)
    {
         frm2.Instance.Show();  
  
         //frm2 cs = new frm2();
        //cs.Show();
    }
  </code></pre>
  
  <p>it work fine the first time, but when i open the frm2 , close it and then again try to open it the compiler give error at  <code>frm2.Instance.Show();</code>   and the error comes is </p>
  
  <pre><code>: Cannot access a disposed object.
  Object name: 'frm2'.
  </code></pre>