I have the following code snippet that limits a TextBox
to receive only numbers and commas:
private void txtTempoAcel1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8 && e.KeyChar == 48)
e.Handled = true;
}
But I have several TextBox
and would like to replicate this code for everyone. Is there any way I can replicate this validation to all TextBox
without putting this code in the KeyPress
event of each of them?