共用方式為


XmlMappedRange.Selected 事件

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

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
Event Selected As DocEvents_SelectionChangeEventHandler
event DocEvents_SelectionChangeEventHandler Selected

備註

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

範例

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

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
private void XmlMappedRange_Selected()
{
    this.CustomerLastNameCell.Selected += 
        new Excel.DocEvents_SelectionChangeEventHandler(
        CustomerLastNameCell_Selected);
}

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

    MessageBox.Show(this.Name + ":" + selectedRange + " was selected.");
}

.NET Framework 安全性

請參閱

參考

XmlMappedRange 介面

Microsoft.Office.Tools.Excel 命名空間