How can I return the key?, mean if I want to allow only integer values in the textbox, how can I don\'t allow user to not enter non-integers, regarding, KeyPress
KeyPress
Create a string with the characters you what to allow the user to enter.
Use KeyDown or KeyUp to handle Special keys
KeyDown
KeyUp
private void tbN1_KeyPress(object sender, KeyPressEventArgs e) { String sKeys = "1234567890ABCDEF"; if (!sKeys.Contains(e.KeyChar.ToString().ToUpper())) e.Handled = true; }