ListBoxes
Xojo Version 2021 r3.1
Description
In Xojo, ListBoxes are used to display multiple lines of information. Each line in a ListBox is referred to as an item. We start counting Items in a ListBox at Zero. ListBox Items have their own properties and methods.
Remember: Any information output to a listbox on the form must be converted to a string first.
Library Location:
ListBoxes are found in the Viewers category in the Xojo Library
Naming Conventions:
The prefix for a ListBox is lst
Adding a ListBox to your form:
- Place the ListBox onto your Form
- In the Inspector, give the ListBox a name (following our naming conventions)
ListBox Item Properties
A ListBox Item can set or retrieve an item value in the ListBox.
Set a ListBox Item Value
lstBox.List(0) = "Bill"
Retrieve a ListBox Item Value and assign it to a Variable
Name = lstBox.List(1)
Return the Number of Items inside a ListBox
lstBox.RowCount
ListBox Item Methods
The following methods allow you to add or remove rows from a listbox.
Add an Item to the ListBox
lstBox.AddRow("Hello")
Inserts an item at a specified location in the ListBox
lstBox.AddRowAt(1, "Hello")
Remove an item at a specified location in the ListBox
lstBox.RemoveRowAt(1)
Removes all items in the listbox
lstBox.RemoveAllRows()