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.
Hi,
Thank you for sharing this. I see now, your approach seems to be the right one to me.
Please do not hesitate to ask if something comes up, I will be very happy to help.
Is there a way to get the UltraNumericEditor to display scientific notation?
Hi Mark,
I don't think so. Do you want to just display it, or also edit? If you worked at it, you might be able to get the numeric editor to display scientific notation, but I don't think it will ever let the user edit in that format.
Dear Mike (and all) --
Would some kind of masked edit control (if is there one of those in the kit?) work for entering and displaying scientific notation?
Or could we (should we) make a custom textbox kind of thing that will validate and handle both standard-notation and scientific-notation input and display?
Thoughts?
Please advise.
(BTW, I am sorry but you might see another thread that I opened on this topic, I apologize for cross-posting, I just thought it deserved its own thread.)
Thanks.
-- Mark Kamoski
As I said, if you really worked at it, you might be able to use a DrawFilter to display scientific notations in a masked edit control, like UltraMaskEditor or UltraNumericEditor. But it doesn't make much difference which one you use, neither one has any support for editing scientific notation values. I guess you might be able to come up with a mask that would allow the user to enter the data as a string, but it won't work as a number, I don't think.
Personally, I would probably use a TextEditor and then just try to validate the data in code, rather than trying to enforce a mask.