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
1270
Problem with MaskInput and MaxValue behaviour
posted

Let's say I want a column for entering decimal degrees for values between -180 and 180, with decimal place precision. I might set a column as:

column.MaskInput = "{double:-3.6}";
column.MinValue = -180;
column.MaxValue = 180;

However, when I enter a value like 180.1, I get an error message when the cell exits edit mode:

Data Error - Unable to update the data value: Input value does not satisfy maximum value constraint.

But why did the editor allow 180.1 to be entered in the first place? That breaks the maximum value?

How do I either prevent this, or stop that Data Error message displaying so that I can put my own validation in?

Thanks

Parents
  • 71886
    Offline posted

    Hello,

    I believe that this is expected since the 'MaxValue' property is not actually restricting you from typing a greater value. It does not allow entering a greater value then the max one. So I tried to get the desired behavior through the following code sample:

            private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
            {
                decimal n;
                bool isDecimal = Decimal.TryParse(e.Cell.GetText(Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw), out n);
                if (isDecimal)
                {
                    if (e.Cell.Column.Key== "Decimal Column" && Convert.ToDecimal(e.Cell.GetText(Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw)) > Convert.ToDecimal(e.Cell.Column.MaxValue))
                    {
                        e.Cell.Value = e.Cell.Column.MaxValue;
                        e.Cell.SelStart = e.Cell.Text.IndexOf(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                    }
                }
            }
    

     

    Please feel free to let me know if I misunderstood you or if you have any other questions.

Reply Children