hi
I insert this on KeyPress event:
e.Handled = !Char.IsNumber(e.KeyChar);
but i dont have the BackSpace key, how to fix it ?
thank's
hi
I insert this on KeyPress event:
e.Handled = !Char.IsNumber(e.KeyChar);
but i dont have the BackSpace key, how to fix it ?
thank's
How about:
e.Handled = !(Char.IsNumber(e.KeyChar) || e.KeyChar == 8);
Or equivalently:
e.Handled = !Char.IsNumber(e.KeyChar) && e.KeyChar != 8;
(As in rm's answer, you can use '\b'
instead of 8 in the above code too.)
here's how to check if backspace was pressed:
if(e.KeyChar == '\b'){//backspace was pressed}