Posted 7 December 2017, 9:11 pm EST
Hi all!
I could not find an example of how to the the binding on the combo box the right way.
Suppose you have a view model object and you want to bind a property of that view model to the C1 combo box. The combo has a data source attached like this:
cmb.ItemsDataSource = GetStudents();
cmb.ItemsValueMember = "Id";
cmb.ItemsDisplayMember = "Name";
where GetStudents method returns a BindingSource object with the proper Id and Name properties. This looks fine.
Now for the binding between a combo and a view model I have used the following line:
cmb.DataBindings.Add(new Binding("Value", viewModelObject, "Cmb", true, DataSourceUpdateMode.OnPropertyChanged));
where ```
viewModelObject.Cmb
The binding works (as expected) if you pick an item from the combo in the runtime, the view model object gets updated.
But if you try in a code to change the value of ```
viewModelObject.Cmb
``` it [b]WON'T[/b] update the selected item in the combo.
What am I doing wrong here?
Thanks in advance for your replies.