共用方式為


XmlMappedRange.Deselected 事件

XmlMappedRange 控制項中的選取範圍移到 XmlMappedRange 控制項以外的區域時發生。

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

語法

'宣告
Event Deselected As DocEvents_SelectionChangeEventHandler
event DocEvents_SelectionChangeEventHandler Deselected

備註

只有當 XmlMappedRange 控制項含有焦點,而焦點從 XmlMappedRange 控制項移轉出時,才會引發這個事件。

範例

下列程式碼會示範 Deselected 事件的處理常式,當取消選取 XmlMappedRange 時,便顯示新選取範圍的位址。這個程式碼範例假設目前工作表包含名為 CustomerLastNameCell 的 XmlMappedRange

Sub CustomerLastNameCell_Deselected(ByVal Target As Excel.Range) _
    Handles CustomerLastNameCell.Deselected
    Dim deselectedRange As String = Target.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("CustomerLastNameCell was deselected. " & _
        "The new selection is " & deselectedRange)
End Sub
private void XmlMappedRange_Deselected()
{
    this.CustomerLastNameCell.Deselected += 
        new Excel.DocEvents_SelectionChangeEventHandler(
        CustomerLastNameCell_Deselected);
}

void CustomerLastNameCell_Deselected(Excel.Range Target)
{
    string deselectedRange = Target.get_Address(Excel.XlReferenceStyle.xlA1);

    MessageBox.Show("CustomerLastNameCell was deselected. The new " +
        "selection is " + deselectedRange);
}

.NET Framework 安全性

請參閱

參考

XmlMappedRange 介面

Microsoft.Office.Tools.Excel 命名空間