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
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.
Boris Toromanov"] 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.
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.
Boris, in addition to my points in my reply, I don't think this is expected behaviour. For instance, with MaxValue as 180 and MaskInput as "{double:3.6}", try typing in 181. You'll notice that the control changes the value to 18.1 instead. That means the mask and the max value are being interpreted during a CellChange event (and that's without your code sample above).
So if, on cell change, the control modifies whole number values that are greater than max value, then surely it should be modifying the decimal values that are greater than the max value. Not doing so is inconsistent.
Anyway, any assistance you can give to resolve this would be much appreciated.
Thanks Boris, that goes halfway to solving the problem.
But it needs to also handle the user entering negative numbers, or deleting the contents of the cell entirely (leaves " . " in cell). Both cause exceptions to be raised.
I can see how to handle the latter, but it's not so clear how to handle the user tabbing to the cell (text becomes selected) and then typing a negative number.