Given a texbox, how can I completely ignore non-digit characters? So if I press “A” or “Z”, those characters would never appear in the textbox. I’d like to run a bit of code if the user tries to input digits and if he tries to input non-digits too..
Share
Try this
if
e.Handledis set to true for non-digits no input will go to the text box; otherwise the event messages flow as they normally would.EDIT:
To handle BackSpace and Delete is a little more work but you can try this
KeyPress event does not get fired for Delete and Backspace keys and hence the override of ProcessCmdKey to manually call the form’s OnKeyPress()