Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

1 of 3
Adam Lear
  • 38.9k
  • 13
  • 83
  • 105

ComboBox SelectedItem vs SelectedValue

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.

Adam Lear
  • 38.9k
  • 13
  • 83
  • 105
lang-cs

AltStyle によって変換されたページ (->オリジナル) /