1
Below follows the code I am trying to limit the use of letters in the text box, the exception of the comma, but it occurs that the comma can be typed a hundred times, I would like the comma to be used only once. How is it right?
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == ',')
{
return;
}
else
{
e.Handled = e.KeyChar != (char)Keys.Back;
}
}