Hi,
I don't know if you are coding for ASP.NET or for Windows Forms?
For ASP.NET, use the ListItem class. For example, you could write:
Combo.Items.Add ( new ListItem ( text, value ) );
If you are using it in Windows Forms, you can use any object you want to
put into the list. You could use instances of an existing class and put
them into the items collection. You would then override the ToString()
method in your class - this will be shown as the text in the list. And
when you access the items you would cast the objects to the proper class.
You could write your own class just for this to be used in ComboBoxes,
say:
class MyListItem {
public string text;
public int value;
public override string ToString () { return text; }
}
(You should of course create properties and not fields directly, but
this should show an example.
Hope that helps,
-Lenard
NowSeeSharp wrote:
Hi
How do I get/set the value property of the combobox???
(similar to value field in the html below
<OPTION value=1>Blah</OPTION>
<OPTION value=2>Foo</OPTION>)
Combo.Items.Add ... ?
What kind of object have I to use ?
Thanx