Combo box undocumented behaviour

i recently came across a very wiered behaviour of combo box (winform )in .net framework

i call it wiered , cuz its not documented anywhere , i tried searching a lot but no results 😦

anyway here it is

when we bind combo box with a data source say Ilist by setting the follwong properties
(in the given order)
Datasource
DisplayMember
ValueMember
what happeend is taht  the SELECETED_INDEX_CHANGED event got fired after setting the datamember and also after setting the valueMember, so if i have handled this event , then i have to chek explicitly that whether it is the wehere datamember is set or value member is set :),
ok u might say its logical, and we can workaround with this by swapping the order of DisplayMember and ValueMember
hmmmm
hmmmmmmmm
that does not work even, whoa say u set in the follwonig order
Datasource
ValueMember
DisplayMember
in this case the select_index_change does not fire at all 😦
so in case where gui layout is depedent on this combo, this wil not work properly , like u have country city combos, and on changing coutnry u chang city list, the first selected_index change event should fire after settting up the list but it does not do it in this manner
any one can explain why ??

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s