Property SelectedIndex
SelectedIndex
Gets or sets the zero-based index of the currently selected item in the control.
public override int? SelectedIndex { get; set; }
Property Value
- int?
A zero-based index of the currently selected item. A value of
null
is returned if no item is selected.
Remarks
For a single selection mode, you can use this property to determine the index of the item that is selected in the control. If the SelectionMode property of the control is set to either Multiple (which indicates a multiple-selection control) 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 control, use the SelectedIndices property. If you want to obtain the item that is currently selected in the control, use the SelectedItem property. In addition, you can use the SelectedItems property to obtain all the selected items in a multiple-selection control.
Exceptions
- ArgumentOutOfRangeException
The assigned value is less than 0 or greater than or equal to the item count.