How to Display the First Item in the ComboBox Drop-down List in Visual Basic

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Display the First Item in the ComboBox Drop-down List in Visual Basic
Add items to a combo box control in VB. (Chad Baker/Ryan McVay/Photodisc/Getty Images)

Dynamically displaying the first item in a combo box control can make your application more user friendly by showing an item in the control when your application loads. Programmers commonly add items to a combo box at start-up, but they fail to display the first item, which makes the control look empty. In Visual Basic you can use the Text property and the Items property to display the first item.

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

    Launch Microsoft Visual Basic Express, click "New Project" on the left pane of your computer screen and double-click "Windows Forms Application" to create a new project.

  2. 2

    Double-click "ComboBox" on the Toolbox pane to create a new combo box control.

  3. 3

    Double-click the form to create a new Load event procedure and add the following code to populate the combo box control with three items:

    Me.ComboBox1.Items.Add("laptop")

        Me.ComboBox1.Items.Add("tablet")
    
        Me.ComboBox1.Items.Add("desktop")
    
  4. 4

    Add the following code to display the first item:

    Me.ComboBox1.Text = Me.ComboBox1.Items(0).ToString()

  5. 5

    Press "F5" to run the program.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.