title: One Event for all my textBoxes. (VC# Windows Form Application)
body: <p>I've searched a lot on this site and found similar questions but none of the answers could help me. So I'm going to ask myself. I have this code that doesn't work when I want to put all my textBoxes to the same event, here it is:</p>
  
  <pre><code>private void OnMouseUp(object sender, MouseEventArgs e)
  {
    TextBox textBox = (TextBox)sender;
    textBox.SelectionLength = 0;
  }
  </code></pre>
  
  <p>I made this code by looking at other answers on this site to similar questions.
  I also made this one by combining answers I found here on this site:</p>
  
  <pre><code>private void OnMouseUp(object sender, MouseEventArgs e)
  {
    foreach (Control x in this.Controls)
    {
      if (x is TextBox)
       {
        ((TextBox)x).SelectionLength = 0;
       }
    }
  }
  </code></pre>
  
  <p>Which also doesn't work...
  Can someone please tell me the easiest way to give the same event to all your textBoxes?</p>