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
You may use keypress event as below. use e.Handled to true to cancel user input
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar)) e.Handled = true; }