Property SelectedIndex
SelectedIndex
Gets or sets the zero-based index of the currently selected item in a ListView.
[Browsable(false)]
public virtual long? SelectedIndex { get; set; }
Property Value
- long?
A zero-based index of the currently selected item. A value of
null
is returned if no item is selected.
Remarks
For a standard ListView, you can use this property to determine the index of the item that is selected in the ListView. If the SelectionMode property of the ListView is set to either Multiple (which indicates a multiple-selection ListView) and multiple items are selected in the list, this property can return the index to any selected item.
To retrieve a collection containing the indexes of all selected items in a multiple-selection ListView, use the SelectedIndices property. If you want to obtain the item that is currently selected in the ListView, use the SelectedItem property. In addition, you can use the SelectedItems property to obtain all the selected items in a multiple-selection ListView.
Exceptions
- ArgumentOutOfRangeException
The assigned value is less than 0 or greater than or equal to the item count.