Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
Hex number editor
posted

Hello,

One of my requirements is allowing the user input an int32 number in hex format, so the user could type "00000000" or "FFFFFFFF".

I'm using an UltraTextEditor with a DataFilter to convert to/from the hex string to the underlying integer. That seems to work fine.

However, I'd like to limit the characters the user can type, so only digits from 0 to 9 and letters from A to F are allowed. What's the best way to do this?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    I think you will probably want to use the KeyDown event for this. You can check the key and if it's not from 0-9 or A-F, you could set e.Handled to true to cancel the keystroke.

    The only tricky part of this is that you also have to handle pasting, so you will need to trap for CTRL+V and maybe Shift+Insert, as well.

Children