The C TextBox control implements a method that only numbers can be entered
- 2021-06-28 13:41:25
- OfStack
Simply write the following code in the keypress event of the control TextBox:
The code is as follows:
if (e.KeyChar == '.' && this.txbEnd.Text.IndexOf(".") != -1)
{
e.Handled = true;
}
if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == '.' || e.KeyChar == 8))
{
e.Handled = true;
}
Where.txbEnd is the name of the textbox control in your current form