共用方式為


XmlMappedRange.Selected 事件 (2007 系統)

更新:2007 年 11 月

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

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

語法

Public Event Selected As DocEvents_SelectionChangeEventHandler

Dim instance As XmlMappedRange
Dim handler As DocEvents_SelectionChangeEventHandler

AddHandler instance.Selected, handler
public 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.");
}

使用權限

請參閱

參考

XmlMappedRange 類別

XmlMappedRange 成員

Microsoft.Office.Tools.Excel 命名空間