Using Listboxes

What is a Listbox?

A listbox is a visual control that enables you to present a list of choices to the user. The user cannot add to the list - they must choose from what is already there.

Adding a Listbox to your formThe Listbox icon on the toolbox

Click on the Listbox icon on the toolbox and then draw out the size for it on your form.

How a Listbox works

A listbox stores a list of strings that is displayed to the user in a scrollable box. All of the strings are stored in the List property of the Listbox. As well as the List property that stores the strings that are visible to the user, there is also a property called itemData that stores an integer that is associated with each visible string but it's not shown to the user.

In the example below, I've stored a list of names in my Listbox and I've stored the age of each person in the itemData slot for each name.

 

[ To be continued ]