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
1045
leading zero problem for UltraNumericEditor
posted

Hi experts,

I have set up control's MaskInput equals "nn", MaxValue equals 99, minValue equals 1.

The issue is when user input single "0", it looks like a valid value for him, but actually the control hold the cursor, which forces user to input another letter. As long as he inputs another letter, say 3, the control is happy with a valid value "03". But users dont know the 1-99 constraint, they click anywhere just after inputing a single 0, and complain why nothing happens.

So my question is is there a way to prohibit user from input a single 0?

Parents
  • 469350
    Offline posted

    Hi,

    There's no built-in way for the control to do that. But there are a couple of approaches you could take.

    What I would do is give the user a message indicating why what they entered is wrong. You could do this by handling the MaskValidationError event. Something like this:


            private void ultraMaskedEdit1_MaskValidationError(object sender, Infragistics.Win.UltraWinMaskedEdit.MaskValidationErrorEventArgs e)
            {
                UltraMaskedEdit maskedEditor = (UltraMaskedEdit)sender;
                if (maskedEditor.Text == "0")
                {
                    MessageBox.Show(string.Format("Value must be between {0} and {1}", maskedEditor.MinValue, maskedEditor.MaxValue));
                }
            }

Reply Children
No Data