Search code examples
infragisticsbindingsourceradiobuttonlist

Ultraoptionset doesn't change the datasource before losing focus


I'm working on a very simple ultraoptionset which consists of two items (string) created at design time. The optionset value is bound (through a binding source) to a string property in the viewmodel. The data source update mode is set to OnPropertyChanged.

The problem is that the viewmodel isn't updated before the whole optionset loses focus in the view. So if I change back and forth between the two values, the property doesn't get the change and hence the validation of the control won't work (because the data isn't updated).

I feel so stupid, because this should be super simple. What am I doing wrong? :D

cheers!


Solution

  • I tested this with NetAdvantage 2012 Volume 2 and found that when changing the option selected through the UI, the setter of the property in the object that I have the UltraOptionSet bound to is updated on property change. This is the code that I used:

    public partial class Form1 : Form
    {
        TestObject to;
        public Form1()
        {
            InitializeComponent();
            to = new TestObject() { Prop = "Two"};
            Binding optionBinding = new Binding("Value", to, "Prop");
            optionBinding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
            this.ultraOptionSet1.DataBindings.Add(optionBinding);
        }
    
    }
    
    public class TestObject
    {
        private string prop;
        public string Prop
        {
            get
            { 
                return prop; 
            }
            set
            {
                System.Diagnostics.Debug.WriteLine("Current value :" + prop + " is being set to " + value);
                if (value != prop) prop = value;
            }
        }
    }
    

    I would recommend verifying that you have the DataSourceUpdateMode set correctly on the binding. If you do you may want to check to see if there is a later service release of the NetAdvantage controls that you can test with.