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
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.
Double-click "ComboBox" on the Toolbox pane to create a new combo box control.
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:
Add the following code to display the first item:
Me.ComboBox1.Text = Me.ComboBox1.Items(0).ToString()
Press "F5" to run the program.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for