This documentation is archived and is not being maintained.

ListObject.SelectedIndex Property

Gets or sets the index of the row that is currently selected.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in

public int SelectedIndex { get; set; }

Property Value

The index number of the currently selected row.

This property is 1-based, not 0-based. The first data row in a ListObject control has an index number of 1.

The following code example creates a ListObject on the current worksheet. It uses the SelectedIndex and AutoSelectRows properties to select the second row and to specify that the entire row is selected when the user clicks a row. The code example also creates an event handler for the SelectedIndexChanged event that displays a message box whenever a new row is selected.

private void ListObject_SelectedIndex()
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(this.Range["A1", "D4"],

    list1.AutoSelectRows = true;
    list1.SelectedIndex = 2;
    list1.SelectedIndexChanged +=
        new EventHandler(list1_SelectedIndexChanged);

void list1_SelectedIndexChanged(object sender, EventArgs e)
    MessageBox.Show("Selected index has changed.");