Hello,
On the attached sample application I have some code in place to handle the KeyDown event and limit the characters the user can type to only allow hex characters (1 to 9 and A to F).
However at run time the grid lets me type any character, even though I'm cancelling the key calling KeyEventArgs.Handled = true inside the event handler.
What am I missing?
It seems like KeyDown is the wrong event to use, even with the standalone .NET TextBox, since the key will still be processed. The correct event to handle is the KeyPress event, though you'll have to modify your IsHexKey method to check for characters instead of a Keys value.
-Matt
Thanks for answer Matt,
I didn't try the KeyPress event. I'm still using the KeyDown event, but instead of calling e.Handled = true I'm using e.SuppressKeyPress = true. Now it works the way I expect.