We have customar table contains Cust_ID, Cust_Name etc…..
for this table Cust_Name is not unique and one Customer name can repeat Number of times.
i am getting data from SQL and binding to ComboBox (winform)
cmbCustomar.Datasource = GetCustomerData(_LocationID);
cmbCustomar.DisplayMember = "Cust_Name";
cmbCustomar.ValueMember = "Cust_ID";
Here the Problem is :
Customer Name : JOHN is repeated 4 times, all Cust_ID are different
when user select JOHN on first Item i am getting correct “SelectedValue”
but if user select 2 nd or 3rd JOHN
Combobox Item it allways default select First Item (Name as JOHN)
and the SelectedValue allways return the First Item Value.
i am not able to find where i am doing wrong, please suggest.
Try changing the following property:
If your ComboBox has
DropDownStyle = DropDown, then the “text” part of the ComboBox is trying to match the first item it can find in the list, and in this case, it ignores the current selected item and finds the first “John” on your list.