Determines the number of items in a ListBox control that are selected.
ListBox, PictureListBox, and ListView controls
listcontrolname.TotalSelected ( )
Argument |
Description |
---|---|
listcontrolname |
The name of the control in which you want the number of items that are selected |
Integer. Returns the number of items in listcontrolname that are selected. If no items in listcontrolname are selected, TotalSelected returns 0. If an error occurs, it returns -1. If listcontrolname is null, TotalSelected returns null.
TotalSelected works only if the MultiSelect property of listcontrolname is TRUE.
If three items are selected in lb_Actions, this example sets SelectedTotal to 3:
integer SelectedTotal
SelectedTotal = lb_Actions.TotalSelected()
These statements in the SelectionChanged event of lb_Actions display a MessageBox if the user tries to select more than three items:
IF lb_Actions.TotalSelected() > 3 THEN
MessageBox("Warning", &
"You can only select 3 items!")
ELSE
... // Some processing
END IF