ComboBox SelectedItem vs SelectedValue

Posted by Anna Lear on Stack Overflow See other posts from Stack Overflow or by Anna Lear
Published on 2010-05-21T15:38:45Z Indexed on 2010/05/21 15:40 UTC
Read the original article Hit count: 237

Filed under:
|
|
|

The following code works as you’d expect — MyProperty on the model is updated when the user picks a new item in the dropdown.

comboBox1.DataBindings.Add("SelectedValue", myModel, "MyProperty", true,
DataSourceUpdateMode.OnPropertyChanged);

The following, however, doesn’t work the same way and the model update isn’t triggered until the input focus moves to another control on the form:

comboBox1.DataBindings.Add("SelectedItem", myModel, "MyProperty", true, 
DataSourceUpdateMode.OnPropertyChanged);

Does anybody know why? I don’t even know where to start investigating the cause. Pointers in the right direction to start the investigation or an outright explanation would be equally appreciated. Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms