title: Stop the Bell on CTRL-A (WinForms)
body: <p>Any ideas how to stop the system bell from sounding when <kbd>CTRL</kbd>-<kbd>A</kbd> is used to select text in a Winforms application?</p>
  
  <p>Here's the problem. Create a Winforms project. Place a text box on the form and add the following event handler on the form to allow <kbd>CTRL</kbd>-<kbd>A</kbd> to select all the text in the textbox (no matter which control has the focus).</p>
  
  <pre><code>void Form1_KeyDown(object sender, KeyEventArgs e)
  {
      if (e.KeyCode == Keys.A &amp;&amp; e.Modifiers == Keys.Control)
      {
          System.Diagnostics.Debug.WriteLine("Control and A were pressed.");
          txtContent.SelectionStart = 0;
          txtContent.SelectionLength = txtContent.Text.Length;
          txtContent.Focus();
          e.Handled = true;
      }
  }
  </code></pre>
  
  <p>It works, but despite e.Handled = true, the system bell will sound every time <kbd>CTRL</kbd>-<kbd>A</kbd> is pressed.</p>
  
  <hr>
  
  <p>Thanks for the reply. </p>
  
  <p>KeyPreview on the Form is set to true - but that doesn't stop the system bell from sounding - which is the problem I'm trying to solve - annoying.</p>