I need to validate characters entered by the user in a MaskedTextBox
. Which characters are valid depends on those already entered. I've tried using IsInputChar
and OnKeyPress
, but whether I return false in IsInputChar
or set e.Handled
to true in OnKeyPress, the box's text is still set to the invalid value.
How do I prevent a keypress from updating a MaskedTextBox
's text?
UPDATE: MaskedTextBox not TextBox. I don't think that should make a difference, but from the number of people telling me that e.Handled
should work, perhaps it does.