Table of Contents

How do I add items to list boxes or combo boxes?

To add or remove items from a list box or combo box control, you must access methods for the Items property. Perform the following steps:

  1. Highlight the control in Object Explorer.
  2. Click Explore Component Properties at the top of Object Explorer.
    Select listBox1 in the Object Explorer

  3. On the list of properties that displays, highlight the Items property.
    Select Items in the Object Explorer
  1. To see a list of available properties and methods, click Configure Type.
  2. In the Configuration dialog, click the methods that you want to use and click OK. The methods that you selected display in the Object Explorer. Commonly used methods are displayed in the following list:
    • Items.Add – Adds an item at the specified index.
    • Items.AddRange – There are two AddRange methods, AddRange(ObjectCollection value) and AddRange((Object[] items). To add an array of items, use the AddRange(Objec[] items) method.
    • Items.Clear – Removes all items from the list box or combo box.
    • Items.Remove – Removes the item with the specified value.
    • Items.RemoveAt – Removes the item at the specified index.

The following automation shows how you can add and remove items from a list box:

Connection block example using the AddRange(Object[]) method

Connection block example using the Add method

Suggest Edit
Did you find this content helpful?

66% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.