ComboBox values and Items

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.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top