XmlMappedRange.Selected 事件

定義

在選取了 XmlMappedRange 控制項時便會發生。

event Microsoft.Office.Interop.Excel.DocEvents_SelectionChangeEventHandler Selected;

事件類型

DocEvents_SelectionChangeEventHandler

範例

下列程式碼 Selected 會示範事件的處理常式,其會顯示所選取之的位址 XmlMappedRange 。 這個程式碼範例假設目前的工作表包含 XmlMappedRange 名為的 CustomerLastNameCell

private void XmlMappedRange_Selected()
{
    this.CustomerLastNameCell.Selected += 
        new Excel.DocEvents_SelectionChangeEventHandler(
        CustomerLastNameCell_Selected);
}

void CustomerLastNameCell_Selected(Excel.Range Target)
{
    string selectedRange = Target.get_Address(Excel.XlReferenceStyle.xlA1);

    MessageBox.Show(this.Name + ":" + selectedRange + " was selected.");
}
Sub CustomerLastNameCell_Selected(ByVal Target As Excel.Range) _
    Handles CustomerLastNameCell.Selected
    Dim selectedRange As String = Target.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox(Me.Name & ":" & selectedRange & " was selected.")
End Sub

備註

當選取範圍變更為控制項時,就會引發這個事件 XmlMappedRange

適用於