Int32EditBox allows typing letters in

Editors for WPF Forum

Posted 4 years ago by Brad Salmon
Version: 19.1.0684
Platform: .NET 3.0 (Core)
Environment: Windows 10 (64-bit)
Avatar

I have an Int32EditBox with the Format set to "D" and I can type letters in the control. When I tab out the letters are "ignored", but the behavior depends on whether the first character entered was a number (in which case the control value is that number) or a letter (in which case the control value is null or 0). In v2015, the Int32EditBox only allowed digits to be entered, which made complete sense since that was the purpose of the control.

Comments (2)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Brad,

Per our reply in this other ticket, we do have a TODO item to possibly add this kind of feature, especially for number-based edit boxes.  It generally doesn't make sense for letters to be entered for them if a pure decimal integer format is being used. 

However the trick is that other scenarios like hex-based formats, currency formats, or custom formats that allow text should still support letters.  What would you suggest as the best way to implement this, knowing that various formats would need to allow letters?


Actipro Software Support

Posted 4 years ago by Brad Salmon
Avatar

I understand you have a tricky situation with the need to support Hex and Currency. Since we have no need for Hex, I'm just overriding the OnKeyDown and adding logic to only allow digits to be entered. Supporting Hex wouldn't be too difficult because it is very well defined format (i.e 0x followed by digits or letters A-F). The Currency is more difficult because of locale and knowing what the currency symbol is. I haven't looked into it, but seems like figuring out the currency symbol wouldn't be hard. 

I had considered changing all of our number and currency controls to be MaskedEdit boxes. The downside is using MVVM and having to bind to a String or else having to create and use a Value converter in the binding.

For Hex and Currency support, you could take the same approach you did with DateTime - create a separate Date control for just date. So have a HexEditBox and CurrencyEditBox that can be optimized for those and then have your Byte, Int16, etc. controls only allow entry of digits. That keeps things simple and efficient and useful for those controls. Just a thought.

I appreciate your response.

- Brad

The latest build of this product (v24.1.1) was released 21 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.