I have a UltraNumericEditor:
ultraNumericEditor1.NumericType = NumericType.Double; ultraNumericEditor1.DataFilter = new PercentageDataFilter(); ultraNumericEditor1.MaskInput = "nnn\\%"; ultraNumericEditor1.SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always; ultraNumericEditor1.MaxValue = 100; ultraNumericEditor1.FormatString = "##0\\%";
ultraNumericEditor1.NumericType = NumericType.Double;
ultraNumericEditor1.DataFilter = new PercentageDataFilter();
ultraNumericEditor1.MaskInput = "nnn\\%";
ultraNumericEditor1.SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always;
ultraNumericEditor1.MaxValue = 100;
ultraNumericEditor1.FormatString = "##0\\%";
When I delete all numbers from the control, that exception is raised from i-don't-know-where, but is not my code, and I don't know how avoid it.
How could I avoid the user introduce values with the keyboard? I only want that the user can modify de value with the spin buttons.
Cheers
Matt, some confusion here.. I'm not the original poster.. I did upgrade to the latest controls as you suggested. The project you sent me was for v8.1. When I upgraded your project to 9.1.20091.2039 (only thing I changed was the assembly references), I did indeed get the exception using the spin buttons:
A first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dllA first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.Exception' occurred in Infragistics2.Win.v9.1.dllA first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
I just tried putting together a simple sample based on what you've said and I can't reproduce the error, either when the form loads or by deleting any text that the control has. Does this sample reproduce the issue on your end? If not, can you alter the sample so that it does illustrate the error?
I also realized that I never answered part of your original question, which is how to prevent the user from editing except when using the spin buttons. The best way I can think of is to use the KeyPress event and mark the Handled property to True.
-Matt
I'm binding through a BindingSource of List<myobject>
It's a System.Nullable<decimal> and I think the value is null when the exception is thrown.I notice I get a couple more of the same exceptions after the form loads and I click on the spin buttons by the blank control. The numbers populate in the control, then further clicks on the spin buttons don't cause anymore exceptions (presumably because there is a number in there now).
You still definitely shouldn't have to do something like this simply to prevent the controls from throwing an exception internally if you're not performing any invalid behavior. How are you binding the controls? What is the DataType and the Value when the exception is being thrown?
I think it might have something to do with databinding.. if I make sure the spinbuttons are enabled only after the form is visible, and turn them off before it closes it seems to work without errors:
private void TaskEditor_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible)
if (budgetHoursUltraMaskedEdit.SpinButtonDisplayStyle != SpinButtonDisplayStyle.OnRight)
budgetHoursUltraMaskedEdit.SpinButtonDisplayStyle =
SpinButtonDisplayStyle.OnRight;
if (maximumHoursUltraMaskedEdit.SpinButtonDisplayStyle != SpinButtonDisplayStyle.OnRight)
maximumHoursUltraMaskedEdit.SpinButtonDisplayStyle =
if (warningHoursUltraNumericEditor.SpinButtonDisplayStyle != Infragistics.Win.ButtonDisplayStyle.Always)
warningHoursUltraNumericEditor.SpinButtonDisplayStyle = Infragistics.Win.
ButtonDisplayStyle.Always;
}
else
if (budgetHoursUltraMaskedEdit.SpinButtonDisplayStyle != SpinButtonDisplayStyle.None)
SpinButtonDisplayStyle.None;
if (maximumHoursUltraMaskedEdit.SpinButtonDisplayStyle != SpinButtonDisplayStyle.None)
if (warningHoursUltraNumericEditor.SpinButtonDisplayStyle != Infragistics.Win.ButtonDisplayStyle.Never)
ButtonDisplayStyle.Never;