GetSelection

[method icon] GetSelection(iOrdinal)

Used to return the index of a selected item within the multiple selection list

iOrdinal Integer Ordinal of item in the multi-selection

Returns result of type Index

Applies to: List Box


>GetSelection

GetSelection

The GetSelection() method is used to return the index of a selected item in a multiple selection list. The specified value corresponds to the ordinal number of the selected item counted from zero, i.e. passing a value of 1 would return the index of the second selected item. This method can only be used with list boxes that have the multiple selection or extended selection properties set. For a simple list box the Index property can be used.

For example, the following would retrieve the text of the first selected item in the list box:

nIndex = .listControl1.GetSelection(0)
IF (nIndex > 0)
	SelString$ = .listControl1.GetString(nIndex)
ELSE
	SelString$="Not selected"
END IF	

If the specified item is not currently selected then a value of -1 is returned.

See also

List Box methods, properties and events.