Visual Basic Reference

Visual Studio 6.0

ListIndex Property

See Also    Example    Applies To

Returns or sets the index of the currently selected item in the control. Not available at design time.

Syntax

object.ListIndex [= index]

The ListIndex property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
index A numeric expression specifying the index of the current item, as described in Settings.

Settings

The settings for index are:

Setting Description
1 (Default for ComboBox, DirListBox, and DriveListBox controls) Indicates no item is currently selected. For a ComboBox control, indicates the user has entered new text into the text box portion. For a DirListBox control, indicates the index of the current path. For a DriveListBox control, indicates the index of the current drive when the control is created at run time.
n (Default for FileListBox and ListBox controls) A number indicating the index of the currently selected item.

Remarks

The expression List(List1.ListIndex) returns the string for the currently selected item.

The first item in the list is ListIndex = 0, and ListCount is always one more than the largest ListIndex value.

For a control in which users can make multiple selections, this property's behavior depends on the number of items selected. If only one item is selected, ListIndex returns the index of that item. In a multiple selection, ListIndex returns the index of the item contained within the focus rectangle, whether or not that item is actually selected.

Show: