Compartir a través de


WorksheetBase.SelectionChange Event

Definition

Occurs when the selection changes on a worksheet.

public:
 event Microsoft::Office::Interop::Excel::DocEvents_SelectionChangeEventHandler ^ SelectionChange;
public event Microsoft.Office.Interop.Excel.DocEvents_SelectionChangeEventHandler SelectionChange;
member this.SelectionChange : Microsoft.Office.Interop.Excel.DocEvents_SelectionChangeEventHandler 
Public Custom Event SelectionChange As DocEvents_SelectionChangeEventHandler 

Event Type

Examples

The following code example demonstrates a handler for the SelectionChange event that displays the sheet name and address of the selected range in the status bar.

This example is for a document-level customization.

private void WorksheetSelectionChange()
{
    this.SelectionChange += 
        new Excel.DocEvents_SelectionChangeEventHandler(
        Worksheet1_SelectionChange);
}

void Worksheet1_SelectionChange(Excel.Range Target)
{
    this.Application.StatusBar = this.Name + ":" +
        Target.get_Address(Excel.XlReferenceStyle.xlA1);
}
Sub Worksheet1_SelectionChange(ByVal Target As Excel.Range) _
    Handles Me.SelectionChange
    Me.Application.StatusBar = Me.Name & ":" & _
        Target.Address(ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
End Sub

Applies to