• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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





0
g46905
Asked:
g46905
  • 4
  • 3
1 Solution
 
S-TwilleyCommented:
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)
0
 
g46905Author Commented:
where can I add this code?

Thanks
0
 
S-TwilleyCommented:
the form load event is a good place probably
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Please suggest.

Thanks
0
 
S-TwilleyCommented:
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
0
 
g46905Author Commented:
When I placed the above statement in formload method, I got an error.Can you tell me where I can place this statement?


Thanks
0
 
S-TwilleyCommented:
After you've added the items:

        ComboBox1.Items.Add("car")
        ComboBox1.Items.Add("flight")
        ComboBox1.Items.Add("ship")
        ComboBox1.Items.Add("bike")
        ComboBox1.SelectedIndex = 0
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now