Link to home
Start Free TrialLog in
Avatar of g46905
g46905

asked on

listing multiple items in the combobox

I am new to VB.NET and was wondeering if some one could help me with the issue I have uisng windows application.My appliation has combobox.When the user uses the drop down from the combobox,it should list the items.

for example:

when the user clicks the arrow on the combobox, he should have,

car
flight
ship
bike

Can you please help me?

Thanks





Avatar of S-Twilley
S-Twilley

ComboBox1.Items.Add("car")
ComboBox1.Items.Add("flight")
ComboBox1.Items.Add("ship")
ComboBox1.Items.Add("bike")

or

Dim items(3) As String
items(0) = "car"
items(1) = "flight"
items(2) = "ship"
items(3) = "bike"

ComboBox1.Items.AddRange(items)
Avatar of g46905

ASKER

where can I add this code?

Thanks
the form load event is a good place probably
Avatar of g46905

ASKER

If I want "car" to be a default, what am I supposed to do ?

Please suggest.

Thanks
you can either set the .Text property of the combo box to "Car"

ComboBox1.Text = "Car"

or set the SelectedIndex to the correct item (index starts at 0... which is the 1st item)

ComboBox1.SelectedIndex = 0
Avatar of g46905

ASKER

When I placed the above statement in formload method, I got an error.Can you tell me where I can place this statement?


Thanks
ASKER CERTIFIED SOLUTION
Avatar of S-Twilley
S-Twilley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial