This is my code:
private void txtAdd_KeyPress(object sender, KeyPressEventArgs e) { if (!(char.IsLetter(e.KeyChar)) && !(char.IsNumber(e.KeyChar)
I like to use !Char.IsControl(e.KeyChar) so that all the "control" characters like the backspace key and clipboard keyboard shortcuts are exempted.
!
If you just want to check for backspace, you can probably get away with:
if (e.KeyChar == (char)8 && ...)