XmlMappedRange.BeforeRightClick 事件

在右击 XmlMappedRange 控件时,但在默认的右击操作之前发生。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler
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;
}

.NET Framework 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间