How to Add an Item to ListBox

How to Add an Item to ListBox thumbnail
Add items to list box using VB.

Providing users with the ability to select one item or multiple items to narrow down their data can make your application more user-friendly. A list box can be created using multiple programming languages. If Visual Basic, you can use the "ListBox.Items" property to add items to the list box. This property also enables you to obtain a reference to the items in the list box control. The reference allows you to add more items, remove items, or obtain a count of items in the control.

Things You'll Need

  • Microsoft Visual Basic Express
Show More

Instructions

    • 1

      Launch Microsoft Visual Basic Express. Click "New Project..." on the left pane of your screen, then select "Windows Forms Application." Click "OK."

    • 2

      Double-click "ListBox" on the Toolbox pane to add a new data list box control. Add a button by double-clicking "Button" on the toolbox.

    • 3

      Double-click "Button1" to create a click event for the button. Type the following code to add three items to the list box control:

      Me.ListBox1.Items.Add("first item")

      Me.ListBox1.Items.Add("second item")

      Me.ListBox1.Items.Add("third item")

    • 4

      Press "F5" to run the program and click "Button1" to add the items to the list box control.

Related Searches:

References

  • Photo Credit Hemera Technologies/AbleStock.com/Getty Images

Comments

You May Also Like

Related Ads

Featured