Click here to Skip to main content
15,311,104 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi my combobox having different items with two items having same value..at the time of slecting one value it canonte showing correct display item..for example a & b have value 2..i wanna B but it selecting A ...plz help me...
Posted
Updated 24-Aug-11 2:50am
v2
Comments
Simon Bang Terkildsen 24-Aug-11 8:47am
   
Winform, WPF, ASP.net? please use "Improve question" and add the appropriate tag to your question.

just try to use combobox.selectedindex or combobox.selecteditem .tostring()
   
It depend on your requirement

if you need to get the selected value then it will be problem with same value in more then one filed

so if you need to get the selected text then try this

combobox.selecteditem.tostring()

this will give you a selected item text


means if you select b then it will return b or if it it a then it will return a

try this....
   
Having duplicate choices in a ComboBox does not seem like a very good design. How would the user differentiate between the choices. If you have a Combo with a list of Customers and you have 2 customers with the same name, how would the user know which is which? Using a ComboBox to select a choice, you should really try to avoid duplicates. If you really cannot get away from having duplicate choices, then you should consider a different control such as a datagrid or listview that can have more than one column to include differentiating information such as a customer address or id or something.

Hope this helps
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900