ComboBox SelectedIndexChanged vs. SelectedValueChanged

  • Thread starter Thread starter Stephen Boutros
  • Start date Start date
S

Stephen Boutros

I'm sure I'm missing something, but what's the difference between these two
events? Both of them always fire one after the other and I can't find a case
where one would fire and not the other.

I tried loading a ComboBox with a list of items, some of which had the same
value, and I expected SelectedValueChanged to only fire when I went from one
item to another with a different value but it fires even if I select another
item of the same value. So what's the point of having these two events?

This is assuming you set your DataSource after the DisplayMember and the
ValueMember (which I understand is the correct way to do things,
notwithstanding all the examples). I realize that if you set the DataSource
first, the events are fired but not always together. But since those are
"throwaway" events anyway, I'm not counting them.

Or, now that I think about it, do they behave differently in a ListBox than
they do in a ComboBox?

Just wondering...

Steph
 
Dear Steph,
SelectedValueChanged is an event of
System.Windows.Forms.ListControl, which is the base class of ComboBox
Control and SelectedIndexChanged is an event of ComboBox Class itself
and SelectedValueChanged is inherited from ListControl.

Regards,
Naveed Ahmad Bajwa
Kalsoft Pvt Ltd
 
Back
Top