ComboBoxes in vb.net

  • Thread starter Thread starter Ryan McConnell
  • Start date Start date
R

Ryan McConnell

Hi,
I have Two string arrays and several questions...
I want to populate a combobox with the contents of both of the arrays.

Is there a way, like in classic asp/html, where i can have a value for
the label and one for the actual value. like in a select:-
<option value="val">Value Displayed</option>

I want to display the name from one array and use the corresponding
value from another as the value.


Also, i've noticed that when i add things to a combobox there is no
initially selected value. is it possible to show a different option at
the start?

Thanks
Ryan
 
Hi Ryan,

You can, but you have you use one array of objects or a datatable for it.

I prefer for that to use a datatable with 2 columns, because it is so easy
to make
You can that do
mycombobox.datasource = mytable
mycombobox.displaymember = mycolumn1
mycombobox.valuemember = mycolmn2

The selectedvalue is set by the mycombobox.selectedindex=y

(If you want a simple example how to make a datatable message that back than
i give it to you)

I hope this helps?

Cor
 
Back
Top