title: close a windows form after another form has been opened
body: <p>In my application, I am using two forms <code>mainform</code> and <code>subForm</code>. The <code>mainForm</code> has simple login application. On click of the button (<code>btnClick</code>) in <code>mainForm</code>(if the login credentials matches), it should get directed to the <code>subForm</code>. This I can do easily. but the problem is that the <code>mainForm</code> still visible and whenever I close the <code>mainForm</code> it is also closing the <code>subForm</code>. Which I dont want to happen. and If I give <code>this.Close()</code> after the function same problem is happening.<br>
  " How to close the <code>mainForm</code> after opening the <code>subForm</code>. "</p>
  
  <p>I have tried the below code:</p>
  
  <p><strong>btnClick Event</strong>:</p>
  
  <pre><code>            subForm newSubForm = new subForm();
              newSubForm.Show();
              newSubForm.RegisterMainForm(this);
              this.Close();
  </code></pre>
  
  <p>RegisterMainForm is just a internal method to consider the actual <code>subForm</code>.</p>