Question : Combobox selectedvalue and selectedindex change unexpectedly

Hi experts,
In my application users can select a client in a combobox showing the names of our clients.
Selecting a client fires the combobox.SelectedIndexChanged event. There I set the client number (which is a string) this way
strCodeClient = Me.cboClients.SelectedValue.ToString()
This far everythings goes well in all cases. When I click on another control the SelectedIndexChanged event and the SelectedValueChanged event are NOT fired again so strCodeClient remains unchanged.
In our client list there are a clients with the same name. Here my application behaves different. Let's presume there are five clients with the name 'KBC'. When the users selects another KBC than the first one, SelectedIndexChanged and SelectedValueChanged are fired and strCodeClient is set perfectly.
BUT, when the users then clicks on another control, SelectedIndexChanged and SelectedValueChanged are fired again and the SelectedValue and SelectedIndex are set to the FIRST instance of KBC. So is also strCodeClient. In another words the wrong KBC wil be selected.
What am I doing wrong??

Answer : Combobox selectedvalue and selectedindex change unexpectedly

What do you mean by another control? do you have two comboboxes in your form?

Please check the "ComboBox1_SelectedIndexChanged" event handles correctly for the respective controls.

Check the following links:
http://stackoverflow.com/questions/354408/net-winforms-combobox-identical-items-and-the-selectedindexchanged-event
http://www.dreamincode.net/forums/showtopic112669.htm

Regards,
Raja Muthaiah
Random Solutions  
 
programming4us programming4us