KeyPressEvent handler

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an event handler for a textBox with the following code inside:

if(!Char.IsNumber(e.KeyChar) == true)
e.Handled = true;

This prevents anyone from entering a non-digit into the text box, but it
also prevents then from using the backspace key. I know there is a way
around this but can't find it.
 
cashdeskmac said:
I have an event handler for a textBox with the following code inside:

if(!Char.IsNumber(e.KeyChar) == true)
e.Handled = true;

This prevents anyone from entering a non-digit into the text box, but it
also prevents then from using the backspace key. I know there is a way
around this but can't find it.
if(!char.IsControl(e.KeyChar)&&!char.IsDigit(e.KeyChar))
 
Back
Top