Worksheet.BeforeRightClick Event (2007 System)
Occurs when the 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 BeforeRightClick As DocEvents_BeforeRightClickEventHandler
'Usage
Dim instance As Worksheet
Dim handler As DocEvents_BeforeRightClickEventHandler
AddHandler instance.BeforeRightClick, handler
public event DocEvents_BeforeRightClickEventHandler BeforeRightClick
public:
event DocEvents_BeforeRightClickEventHandler^ BeforeRightClick {
void add (DocEvents_BeforeRightClickEventHandler^ value);
void remove (DocEvents_BeforeRightClickEventHandler^ value);
}
JScript does not support events.
Examples
The following code example demonstrates a handler for the BeforeRightClick event that cancels the right-click action on the current worksheet. The event handler informs the user that right-clicking is not allowed for the worksheet, and then sets the Cancel parameter of the DocEvents_BeforeRightClickEventHandler event handler to true so that Microsoft Office Excel cancels the right-click action.
This example is for a document-level customization.
Sub Worksheet1_BeforeRightClick(ByVal Target As Excel.Range, _
ByRef Cancel As Boolean) Handles Me.BeforeRightClick
MsgBox("Right-clicking in this sheet" & " is not allowed.")
Cancel = True
End Sub
private void WorksheetBeforeRightClick()
{
this.BeforeRightClick +=
new Excel.DocEvents_BeforeRightClickEventHandler(
Worksheet1_BeforeRightClick);
}
void Worksheet1_BeforeRightClick(Excel.Range Target,
ref bool Cancel)
{
MessageBox.Show("Right-clicking in this sheet" +
" 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.