WorkbookBase.SheetBeforeRightClick 事件

在右击任意工作表之后,默认的右击操作之前发生。

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

语法

声明
Public Event SheetBeforeRightClick As WorkbookEvents_SheetBeforeRightClickEventHandler
public event WorkbookEvents_SheetBeforeRightClickEventHandler SheetBeforeRightClick

备注

此事件不会发生于图表工作表上。

示例

下面的代码示例演示 SheetBeforeRightClick 事件的处理程序。该事件处理程序通知用户不允许右击工作表,然后将 WorkbookEvents_SheetBeforeRightClickEventHandler 事件处理程序的 Cancel 参数设置为 true,以便 Microsoft Office Excel 取消该右击操作。

此示例针对的是文档级自定义项。

Sub ThisWorkbook_SheetBeforeRightClick(ByVal Sh As Object, _
    ByVal Target As Excel.Range, ByRef Cancel As Boolean) _
    Handles Me.SheetBeforeRightClick

    MsgBox("Right-clicking in " & CType(Sh, Excel.Worksheet).Name & _
        " is not allowed.")
    Cancel = True
End Sub
private void WorkbookSheetBeforeRightClick()
{
    this.SheetBeforeRightClick +=
        new Excel.WorkbookEvents_SheetBeforeRightClickEventHandler(
        ThisWorkbook_SheetBeforeRightClick);
}

void ThisWorkbook_SheetBeforeRightClick(object Sh,
    Excel.Range Target, ref bool Cancel)
{
    MessageBox.Show("Right-clicking in " + ((Excel.Worksheet)Sh).Name +
        " is not allowed.");
    Cancel = true;
}

.NET Framework 安全性

请参见

参考

WorkbookBase 类

Microsoft.Office.Tools.Excel 命名空间