Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ListObject.SelectionChange Event

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Occurs when the selection changes inside the ListObject control.

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

This event is raised when any selected range inside the ListObject changes.

This event is not raised when focus moves from inside a ListObject control to outside of the ListObject control. It is raised when focus moves from outside a ListObject control to the ListObject control.

The following code example creates a ListObject and then creates an event handler for the SelectionChange event. To test the event handler, select a cell in the ListObject and then select a different cell in the ListObject.

This version is for a document-level customization.

private void ListObject_SelectionChange()
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(
        this.Range["A1", "C4"], "list1");
    list1.SelectionChange += new Microsoft.Office.Interop.
        Excel.DocEvents_SelectionChangeEventHandler(
        list1_SelectionChange);
}

void list1_SelectionChange(Microsoft.Office.Interop.Excel.Range Target)
{
    MessageBox.Show("The selection in the list object has changed.");
}

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

private void ListObject_SelectionChange()
{
    Worksheet vstoWorksheet =
            Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]); ;
    ListObject list1 =
        vstoWorksheet.Controls.AddListObject(
        vstoWorksheet.Range["A1", "C4"], "list1");
    list1.SelectionChange += new 
        Excel.DocEvents_SelectionChangeEventHandler(
        list1_SelectionChange);
}

void list1_SelectionChange(Excel.Range Target)
{
    System.Windows.Forms.MessageBox.Show("The selection in the list object has changed.");
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.