Export (0) Print
Expand All

ListObject.Selected Event

Occurs when the ListObject control is selected.

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

event DocEvents_SelectionChangeEventHandler Selected

This event is raised when the selection changes to the ListObject control.

The following code example creates a ListObject and then creates an event handler for the Selected event. To test the event handler, ensure that the ListObject is not selected, and then select it.

This version is for a document-level customization.

private void ListObject_Selected()
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Range["A1", "C4"], "list1");

    list1.Selected += new Microsoft.Office.Interop.Excel.

void list1_Selected(Microsoft.Office.Interop.Excel.Range Target)
    MessageBox.Show("The list object has been selected.");

This version is for an application-level add-in.

private void ListObject_Selected()
    Worksheet vstoWorksheet =
    ListObject list1 =
        vstoWorksheet.Range["A1", "C4"], "list1");

    list1.Selected += new 

void list1_Selected(Excel.Range Target)
    System.Windows.Forms.MessageBox.Show("The list object has been selected.");

© 2014 Microsoft