How to implement a number maximum with a decimal step limit

Editors for WPF Forum

Posted 12 years ago by Greg Shaffer
Version: 11.2.0552
Avatar
Hi,

I have these two requirements:
1) I need to implement a maximum of 64.0 for a Double value
2) The double value can only have steps of "0.5"

I would prefer a behavior where the user's typing is restricted, as opposed to a post edit validation mechanism (ValidatesOnDataErrors).

I've implemented a MaskedTextBox with the following Mask: "[0-9]{0,2}[.][0,5]"
But, there appears to be no Maximum property on a MaskedTextBox.

I've also implemented a DoubleEditBox, with my maximum of 64.0, but I cannot figure out a way to implement the "0.5" increment limitation that is applied while the user types.

Is there an easy way to achieve this goal?

Thanks,
Greg

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Greg,

For the DoubleEditBox, you would probably need to set PartValueCommitTriggers to All and then handle the ValueChanging event to coerce the value as desired.

For the MaskedTextBox, you could handle the TextChanging event and verify that it does not exceed a given maximum.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.