title: c# WinForms form still closes after setting e.Cancel = true in Form_FormClosing event
body: <p>This is the code in question:</p>
  
  <pre><code>    private void FormAccounting_FormClosing(object sender, FormClosingEventArgs e)
      {
          Properties.Settings.Default.FormAccountingLocation = this.Location;
          Properties.Settings.Default.Save();
          if (IsEditing)
          {
              MessageBox.Show("Please save or cancel open transactions before closing the accounting window.", "Open Transactions", MessageBoxButtons.OK, MessageBoxIcon.Information);
              e.Cancel = true;
          }
      }
  </code></pre>
  
  <p>I've added breakpoints to the <code>e.Cancel = true;</code> line to ensure it's being executed.</p>
  
  <p>The form closes immediately after clicking Ok.</p>
  
  <p>Here's the code that calls FormAccounting:</p>
  
  <pre><code>    private void buttonAccounts_Click(object sender, EventArgs e)
      {
          FormAccounting NewFormAccounting = new FormAccounting();
          NewFormAccounting.Show();
      }
  </code></pre>