Share via


XmlMappedRange.BeforeDoubleClick 事件

在按兩下 XmlMappedRange 控制項時 (在預設的按兩下動作前) 發生。

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

語法

'宣告
Event BeforeDoubleClick As DocEvents_BeforeDoubleClickEventHandler
event DocEvents_BeforeDoubleClickEventHandler BeforeDoubleClick

範例

下列程式碼範例展示 BeforeDoubleClick 事件的處理常式,此處理常式會取消 XmlMappedRange 中的按兩下動作。 事件處理常式會告知使用者不允許 XmlMappedRange 的按兩下動作,然後將 DocEvents_BeforeDoubleClickEventHandler 事件處理常式的 Cancel 參數設定為 true,令 Microsoft Office Excel 取消按兩下動作。 這個程式碼範例假設目前工作表包含名為 CustomerLastNameCell 的 XmlMappedRange

Sub CustomerLastNameCell_BeforeDoubleClick(ByVal Target As Excel.Range, _
    ByRef Cancel As Boolean) Handles CustomerLastNameCell.BeforeDoubleClick
    MsgBox("Double-clicking in this range is not allowed.")
    Cancel = True
End Sub
private void XmlMappedRange_BeforeDoubleClick()
{
    this.CustomerLastNameCell.BeforeDoubleClick += 
        new Excel.DocEvents_BeforeDoubleClickEventHandler(
        CustomerLastNameCell_BeforeDoubleClick);
}

void CustomerLastNameCell_BeforeDoubleClick(Excel.Range Target, 
    ref bool Cancel)
{
    MessageBox.Show("Double-clicking in this range " +
        " is not allowed.");
    Cancel = true;
}

.NET Framework 安全性

請參閱

參考

XmlMappedRange 介面

Microsoft.Office.Tools.Excel 命名空間