if (System.Text.RegularExpressions.Regex.IsMatch("[^0-9]", txt_Digit8.Text)) { MessageBox.Show("Please enter only numbers."); txt_Digit8.Text.Remove(txt_Digit8.Text.Length - 1); }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { textBox1.MaxLength = 1; if (Char.IsNumber(e.KeyChar)) { e.Handled = false; } else { e.Handled = true; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)