Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When binding to a combobox SelectedItem the change is only notified on lost focus. How to notify when selection is changed?

I've bound it using

cmbPeriod.DataBindings.Add("SelectedItem", Presenter, "SelectedDate", true, DataSourceUpdateMode.OnPropertyChanged);

But it only fires to the bound model when I tab out of the control, I'd like it to fire the moment the users makes a new selection.

EDIT: Ok so I tried binding using SelectedValue instead and leaving the ValueMember as null. This had the effect of updating the source as soon as the combobox changes with the correct object, however now the combobox ignores updates from the source!!

I see it requesting the binding at runtime and my source property returns the correct object, which is the the same type the combobox will update the source with on change. Ugh! So close:(

like image 291
Mr_E Avatar asked May 17 '12 14:05

Mr_E


1 Answers

cmbPeriod.DataBindings.Add("SelectedValue", Presenter, "SelectedDate", true, DataSourceUpdateMode.OnPropertyChanged); 

binding to SelectedValue works on change

like image 101
diimdeep Avatar answered Sep 19 '22 00:09

diimdeep