//Name of textbox is textBox1 and event is KeyDown
private void textBox1_KeyDown(object sender, KeyEventArgs e) {
if (!((e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) || ((e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9) && (!e.Shift)) || e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete || e.KeyCode == Keys.Alt || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Shift || e.KeyCode == Keys.Home || e.KeyCode == Keys.End || e.KeyCode == Keys.Decimal))
e.SuppressKeyPress = true; }
|