Setting Properties for Individual Items in a List Box
The properties summarized in the following table can be set for an individual item in a ListBox control.
Property | Description |
---|---|
itemBackColor | Contains the background color of each item |
itemData | Contains a specific number for each item |
itemEnabled | Specifies whether individual items are disabled or enabled |
itemExpanded | Contains the expansion (or collapse) status of each item |
itemForeColor | Contains the text color of each item |
itemLevel | Contains the hierarchical level of each item |
itemObject | Contains an object for each entry |
itemPicture | Contains a picture for individual items |
itemPictureType | Contains the type of picture of each item |
itemSelected | Contains the selection status of each item |
itemText | Contains the text of an item |
Each of these properties is an array of values, with the same number of entries as items in the list box. To set a property for an item in a list box, you must also specify the index of the item; for example:
myListBox.itemText[1]
The previous example returns the text for the first item in a list box called myListBox.
The code fragment in the following example sets the itemText property for the tenth item in this list box.
myListBox.itemText[10] := "Fred";
See also "Using a List Box to Display a Hierarchy or Tree", in the following subsection.