Share via


XmlMappedRange.BeforeRightClick 事件 (2007 系統)

更新:2007 年 11 月

XmlMappedRange 控制項上按一下滑鼠右鍵時 (在預設的按一下滑鼠右鍵動作前) 發生。

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

語法

Public Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler

Dim instance As XmlMappedRange
Dim handler As DocEvents_BeforeRightClickEventHandler

AddHandler instance.BeforeRightClick, handler
public event DocEvents_BeforeRightClickEventHandler BeforeRightClick

範例

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

Sub CustomerLastNameCell_BeforeRightClick(ByVal Target As Excel.Range, _
    ByRef Cancel As Boolean) Handles CustomerLastNameCell.BeforeRightClick
    MsgBox("Right-clicking in this range is not allowed.")
    Cancel = True
End Sub
private void XmlMappedRange_BeforeRightClick()
{
    this.CustomerLastNameCell.BeforeRightClick += 
        new Excel.DocEvents_BeforeRightClickEventHandler(
        CustomerLastNameCell_BeforeRightClick);
}

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

使用權限

請參閱

參考

XmlMappedRange 類別

XmlMappedRange 成員

Microsoft.Office.Tools.Excel 命名空間