ComboBox values and Items

  • Thread starter Thread starter FaWiizio
  • Start date Start date
F

FaWiizio

Is it possible to add an item to a combobox this way:

ComboBox1.Items.Add("Cool!")

AND assign to this new Item a unique index ?

As in HTML

<option value="1">Cool</option>

I would like to override standard indexes (0,1,2,3,...) and write mine.

Is it possible?

Regards.
 
You can create your own class for the items. Make it contain an integer
for the index and a string. Override the ToString method to return the
string, that is how the combobox gets the text to display for the item.

Add objects from your class to the combobox. When the user selects an
item you cast the selected item back to your class and get the index.
 
Back
Top