Workbook.SheetBeforeRightClick Event (2007 System)
Occurs when any worksheet is right-clicked, before the default right-click action.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
Public Event SheetBeforeRightClick As WorkbookEvents_SheetBeforeRightClickEventHandler
'Usage
Dim instance As Workbook
Dim handler As WorkbookEvents_SheetBeforeRightClickEventHandler
AddHandler instance.SheetBeforeRightClick, handler
public event WorkbookEvents_SheetBeforeRightClickEventHandler SheetBeforeRightClick
public:
event WorkbookEvents_SheetBeforeRightClickEventHandler^ SheetBeforeRightClick {
void add (WorkbookEvents_SheetBeforeRightClickEventHandler^ value);
void remove (WorkbookEvents_SheetBeforeRightClickEventHandler^ value);
}
JScript does not support events.
Remarks
This event does not occur on chart sheets.
Examples
The following code example demonstrates a handler for the SheetBeforeRightClick event. The event handler informs the user that right-clicking is not allowed for the worksheet, and then sets the Cancel parameter of the WorkbookEvents_SheetBeforeRightClickEventHandler event handler to true so that Microsoft Office Excel cancels the right-click action.
This example is for a document-level customization.
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.