Table of Contents

Property SelectedIndex

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

SelectedIndex

Gets or sets the zero-based index of the currently selected item in a ListBox.

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 standard ListBox, you can use this property to determine the index of the item that is selected in the ListBox. If the SelectionMode property of the ListBox is set to either Multiple (which indicates a multiple-selection ListBox) 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 ListBox, use the SelectedIndices property. If you want to obtain the item that is currently selected in the ListBox, use the SelectedItem property. In addition, you can use the SelectedItems property to obtain all the selected items in a multiple-selection ListBox.

Exceptions

ArgumentOutOfRangeException

The assigned value is less than 0 or greater than or equal to the item count.