Selecting an item or items in a list box
To select an item in a single selection list box the SetSelection() method may be used. The index of the item is used to specify which item is to be selected, for example:
.listControl1.SetSelection(5)
would select the item with the index of 5. The GetIndex() method can be used to return the index of an item. Therefore to select a specific string within a list box the following could be used:
.listControl1.SetSelection(.listControl1.GetIndex(String$))
If no index value is specified with the SetSelection() method then any existing selection, if any, is cleared.
If the list box is a multiple or extended selection list box (See Selection) then the AddSelection() method may used to select additional items, for example:
.listControl1.AddSelection(Item)
The SelectItem() method may be used to select and deselect items in both single and multiple selection listboxes using the item's handle value.
Handle = .listControl1.Add(ItemText$) .listControl1.SelectItem(Handle) .listControl1.SelectItem(Handle, FALSE)
It is also possible to select items using an object reference to the item's Selected property.
Object Item = .listControl1.Add(ItemText$) Item.Selected = TRUE