This project is read-only.
1
Vote

MaxLenght bug.

description

I tried to use the MaxLength property of the control and it does not work out of the box as supposed to be. In fact the lack of it leaves open for an overflow exception when exceeding the value of the decimal value of the currency control.

I modified the control with a minor patch on the TextBox_PreviewKeyDown event and it seems to work now.

I'll leave the patch here so anyone can implement or better if the creator of the control can update to fix this bug.
e.Handled = true;

//patch
if ((sender as TextBox).MaxLength!=0 && (sender as TextBox).MaxLength <= (sender as TextBox).Text.Length)
                {
                    return;
                } //patch
                else if (Number < 0) //Push the new number from the right
                {
                    Number = (Number * 10M) - (GetDigitFromKey(e.Key) / 100M);

comments

abbaye wrote Jan 24, 2016 at 8:49 PM

Thank for issues i have implemented in my version on this control.


another alternative :)
            if (tb.MaxLength != 0 && Number.ToString().Length > tb.MaxLength)
                return;