title: Prevent one form to open Twice while Passing some Data
body: <p>I'm working on a Inventory Software. In this Software when the user will press Ctrl+Space buttons then system will open a form (frmProducts.cs) showing all the products list. On this form user can search through products by name, select the product from this form and then press button Select. The selected product wll be shown on sale invoice product name text box along with the product code.</p>
  
  <p>Now the problem is occuring when the user selects the product program opens a new sale invoice form and don't load the data into the old one. The program should show already opened form with the data filled.</p>
  
  <p>The code I wrote to open the products info is:</p>
  
  <pre><code>  private void txtProductCode1_KeyDown(object sender, KeyEventArgs e)
          {
              if (e.Control &amp;&amp; e.KeyCode == Keys.Space)
              {
                 // frm4.Instance.Show();
                  frmProducts cs = new frmProducts();
                  cs.Show();
              }
          }
  </code></pre>
  
  <p>The code i wrote on frmProducts Select button is:</p>
  
  <pre><code>int ItemNo;
                  string sql;
  
                  if (lvProducts.SelectedItems.Count == 0)
                  {
                      MessageBox.Show("Please Select Atleast one Column", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                  }
  
                  else
                  {
                      ItemNo = Convert.ToInt32(lvProducts.SelectedItems[0].Text.ToString());
  
                      sql = "";
                      sql += "SELECT * FROM ProductLog WHERE ProductLog.ItemNo = " + ItemNo + "";
  
  
                      SqlConnection cn = new SqlConnection();
                      SqlCommand rs = new SqlCommand();
                      SqlDataReader sdr = null;
                      clsConnection clsCon = new clsConnection();
  
  
                      clsCon.fnc_ConnectToDB(ref cn);
  
  
                      rs.Connection = cn;
                      rs.CommandText = sql;
                      sdr = rs.ExecuteReader();
  
                      this.Close();
  
  
                      frmSaleInvoice frm = new frmSaleInvoice(ref sdr);
                      frm.ShowDialog();                   
  
                      sdr.Close();
                      rs = null;
                      cn.Close();
                  }
  </code></pre>
  
  <p>and the code in frminvoice to catch data is : </p>
  
  <pre><code>public frmSaleInvoice(ref SqlDataReader sdr)
      {
  
          InitializeComponent();
  
              while (sdr.Read())
              {
                  txtProductCode1.Text = Convert.ToString(sdr["ProductCode"]);
              }            
      }        
  </code></pre>
  
  <p>I've also tried this code on Select button but it just don't load anything into the sale invoice:</p>
  
  <pre><code>frmSaleInvoice frm = new frmSaleInvoice(ref sdr);
                      if (frm.Visible)
                      {
                          frm.BringToFront();
                      }
  </code></pre>
  
  <p>and have also tried this</p>
  
  <pre><code>            frmSaleInvoice frm = new frmSaleInvoice(ref sdr);
              frmSaleInvoice.Instance.Show();
  </code></pre>
  
  <p>I also tried to pass value with <code>frmSaleInvoice.Instance.Show();</code> but it's not allowing me to pass data like  <code>frmSaleInvoice.Instance.Show(ref sdr);</code> </p>
  
  <p>Please help me out, i am really stucked in it.</p>
  
  <ul>
  <li>either tell me how can i pass value thoguh instance </li>
  <li>or any other way to do this?</li>
  </ul>
  
  <p>Any suggestions will be appreciated.!</p>