title: Opening a previous form when one is closed
body: <p>First of all, I am a newcomer to C# and programming in general. I've searched pretty thoroughly, but I can only find instances where someone wants to open another form and hide the one that the button was pressed on.</p>
  
  <p>In this instance, I'm having issues with my program continuously running when I press the (X) on any form other than the main "Form1".The form-to-form navigation works fine. i.e.: clicking a button hides the main window and opens the appropriate form, and the "back" button on that form hides itself and shows (I guess another instance) of the previous "main" form. --I could probably use some guidance in that, too. lol </p>
  
  <p>I wouldn't mind if it closed the entire application if the X was pressed, but I need to have the "X" present on all windows and all windows need to exit the entire app if the X is pressed. Any suggestions? </p>
  
  <p>Thanks in advance,</p>
  
  <p>Code:</p>
  
  <p><strong>Form1:</strong></p>
  
  <pre><code>    public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }
              public void btnTransaction_Click(object sender, EventArgs e)
              {
                  Transaction transactionForm = new Transaction();
                  Form mainForm = this;
                  transactionForm.Show();
                  mainForm.Hide();
              }
          }
  </code></pre>
  
  <p><strong>Transaction Form:</strong></p>
  
  <pre><code>    public partial class Transaction : Form
          {
              public Transaction()
              {
                  InitializeComponent();
              }
              private void button4_Click(object sender, EventArgs e)
              {
                  Form1 mainForm = new Form1(); //not sure if I'm doing this right..
                  this.Hide();                  //I don't know how to "reuse" the original Form1
                  mainForm.Show();
              }
          }
  </code></pre>