I have an Infragistics UltraNumericEditor (version 5.3, quite old) managing the form.
If I set the .Value field to a smaller .MinValue or something larger .MaxValue, then I get a System.Exception message with the message:
The Value property cannot be set to a value outside the range defined by the MinValue and MaxValue properties.
The signatures of the corresponding fields on UltraNumericEditor are as follows:
public object MinValue { get; set; }
public object MaxValue { get; set; }
public object Value { get; set; }
This can happen many hundreds of times through our code base, so instead of checking MinValue and MaxValue against the value that we try to set each time, I thought I would subclass the control and put a check there:
public class OurNumericEditor : Infragistics.Win.UltraWinEditors.UltraNumericEditor
{
public object Value
{
get
{
return base.Value;
}
set
{
double min = (double)base.MinValue;
double max = (double)base.MaxValue;
double attempted = (double)value;
if (attempted > max)
base.Value = max;
else if (attempted < min)
base.Value = min;
else
base.Value = value;
}
}
}
, , , MinValue MaxValue , InvalidCastException, .
, , , , , .
?