Validate character entry without losing focus

Editors for WPF Forum

Posted 7 years ago by Miles Merckel
Version: 17.1.0652
Avatar

Hi

Using the 2017 editors I've realised the various edit boxes don’t validate characters as they are typed. This was convenient with the old version which prevented say alpha characters being accepted for DoubleEditBox or prevented Maximum and Minimum values being exceeded.

 

I can use the PreviewTextInput handler below as a workaround

    private void doubleBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
    {
        string refString = "0123456789.";

        if (refString.IndexOf(e.Text) < 0)
            e.Handled = true;
    }

The above will start to get messy if I need to check for max and mins. Couldn't find anything in the documentation is there a way to have the old behaviour without using the legacy product?

 

Many Thanks

Miles

Comments (2)

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

Hi Miles,

Yes the older Editors used completely custom edit controls that allowed for some features like restricted input via masking.  In the new Editors, we switched to using a nested normal TextBox for entry.  This keeps the object model a lot simpler and allows for some other nice features like IME input and better selection/freeform typing, but does lose some of that other functionality.

One problem is that there are certain scenarios like where NaN is allowed, where other characters need to be supported.  And certain cultures use other characters than '.' as a decimal delimiter.

We will write down to try and look into this to see if we can add some features that would help block certain input.


Actipro Software Support

Posted 7 years ago by Miles Merckel
Avatar

Hi

Thanks for the reply, I was hoping I’d missed a property to allow the old functionality. I probably wouldn’t use the new editor control as it stands.

Thanks Miles

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.