title: C# TextBox filtering
body: <p>I want to filter the data that user enters. I just want him to be able to add numbers and , or . and to delete in case of mistake.</p>
  
  <p>I have this code:</p>
  
  <pre><code>private void textBox_KeyPress(object sender, KeyPressEventArgs e)
  {
      if ((char.IsDigit(e.KeyChar) == false) &amp;&amp; 
          (e.KeyChar != '\b') &amp;&amp; (e.KeyChar != ',')) 
              e.Handled = true;
      if (e.KeyChar == ',' &amp;&amp; (sender as TextBox).Text.IndexOf(',') &gt; 0) 
          e.Handled = true;
  }
  </code></pre>
  
  <p>Now I have two problems:<br>
  1) I have two textBoxes (which are fields where user should write some numbers which will be added/divided etc.) and when I write only a comma in one of them there is an error.<br> 
  2) I also want to make it possible to use ".", but I want it to change into ",".</p>