adding items to comboboxes

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
If I add a list of items to a combobox any ideas on how I solve the following:

I assign 5 values to a combobox using the items.add method, but when I try to query the users selection using selectedvalue it returns nothing. Is there some other way to add items, or is there a step I have missed.

Also how do I make the first item added to the list appear in the combobox, cuurently it appears blank and the user has to click on the control to display the values.

On other comboboxes on the form which I have pre assigned values I use selectedvalue and it works ok
 
Aha got the query result ok, SelectedItem not SelectedValue.

Just need to suss the displaying the first item...
 
Aha.....that works a treat...ta

Also I was always taught the following about programming..

There is no wrong way to program, as if it works it's right. There is only efficient and inefficient ways to program!

PS like you name.......does it mean what it I think it means? :-))
 
I'd use "ComboBox1.SelectedIndex = 0" to select the first item. Setting the Text property may work, but it will cause an error if the style is set to dropdownlist (where you can't type in values in the ComboBox).

-Nerseus
 
Back
Top