Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void txt_KeyPress(object sender, KeyPressEventArgs e)
- {
- //ввод только цифр с одной точкой (запятой)
- if ((e.KeyChar == '.') || (e.KeyChar == ','))
- {
- TextBox txt = (TextBox)sender;
- if (txt.Text.Contains(".") || txt.Text.Contains(","))
- {
- e.Handled = true;
- }
- return;
- }
- if (!(Char.IsDigit(e.KeyChar)))
- {
- if ((e.KeyChar != (char)Keys.Back))
- {
- e.Handled = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement