I have comboBox component and i am adding items like comboBox1.Items.Add("Item1"). But i alo need to know some other info about this Item. So if i click “Item1” i need to get "102454".
Can i somehow save 102454 to “Item1” on combobox.
At web aplication there is dropdown list which look like
<select>
<option value="102454">Item1</option>
</select>
and when i click “Item1” i get 102454.
Can i do this in windows desktop applicatin with combobox?
Edit better solution:
Use a
KeyValuePairandValueMember\DisplayValue:As Kristian points out this can be extended to be even more flexible – you can put whatever object you like into the list of items, and set the value and display members on the combobox to be whatever property path you want.
To get the key back later you can do this: