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
260
Binding an UltraNumericEditor to a Nullable Decimal.
posted

Hello,

I am working with version 20141.2035 and am trying to bind an UltaNumericEditor to a nullable property (NullableProperty).  I am doing the following

// designer settings

myUltraNumericEditor.FormatString = "#,###,###.#######";
myUltraNumericEditor.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
myUltraNumericEditor.MaskInput = "{double:9.6}";
myUltraNumericEditor.MaxValue = 1E+16D;
myUltraNumericEditor.MinValue = -1E+16D;
myUltraNumericEditor.Name = "ultraNumericEditorWireFxRate";
myUltraNumericEditor.Nullable = true;
myUltraNumericEditor.NumericType = Infragistics.Win.UltraWinEditors.NumericType.Decimal;
myUltraNumericEditor.PromptChar = ' ';

//code behind

public decimal? NullableProperty {get; set;}

myUltraNumericEditor.DataBindings.Add("Value", this, "NullableProperty", false, DataSourceUpdateMode.OnPropertyChanged);

I have no problems using this binding approach when using a non nullable decimal.

Thanks in advance for any help

Parents
  • 469350
    Offline posted

    Hi,

    Is the code you have here in the designer.cs file for the form? Or are you running it in the Form.cs itself or some other method?

    I tried it out and the code you have here works fine if it's int he Form designer code. But if you take the same code and put it in Form_Load, it raises an exception.

    The exception is "The specified mask is not compatible with the current value of the 'NumericType' property."

    The reason for this exception appears to be that you are setting the MaskInput before you set the NumericType property. If you do this in the designer code, then the control handles this, but if you set it in your code, it won't work. The fix is very simple in that case, of course. Just set the MaskInput AFTER setting the NumericType property.

    I have attached my sample here so you can check it out. In my sample, I set the MaskInput and other properties inside the designer code and it's working fine for me.

    WindowsFormsApplication31.zip
Reply Children