title: create a textbox that accepts only numeric values. Problem with designer mode
body: <p>i have a form that has some six - seven text boxes. few text boxes needs to accept only numeric chars i.e from 0-9, a decimal poing and + or - </p>
  
  <p>i handled the textbox key press event </p>
  
  <p>private void textBox1_KeyPress(object sender, KeyPressEventArgs e) 
  { 
      if (!char.IsControl(e.KeyChar)<br>
          &amp;&amp; !char.IsDigit(e.KeyChar)<br>
          &amp;&amp; e.KeyChar != '.') 
      { 
          e.Handled = true; 
      } </p>
  
  <p>} </p>
  
  <p>Now i have to write the same code for all the textboxes which i felt is redudant. 
  I created a new class MyTextBox derived from TextBox and added the above code into it. </p>
  
  <p>In the designer mode i drag and drop the textbox control .. go to the Designer.cs file and change the line to </p>
  
  <p>private MyTextbox m_txtName = new MytextBox(); </p>
  
  <p>Now the problem is that if i add a new button or any control to teh form the designer.cs file is changed/updated... and the aboe line is changed to the normal TextBox and i got to go replace this everytime ... can i avoid this ?</p>
  
  <p>Note: I do not want to use MasktextBox or numericKeydown control.</p>