WorksheetBase.BeforeRightClick Event


Occurs when the worksheet is right-clicked, before the default right-click action.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public event DocEvents_BeforeRightClickEventHandler BeforeRightClick

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.

private void WorksheetBeforeRightClick()
    this.BeforeRightClick += 
        new Excel.DocEvents_BeforeRightClickEventHandler(

void Worksheet1_BeforeRightClick(Excel.Range Target, 
    ref bool Cancel)
    MessageBox.Show("Right-clicking in this sheet" +
        " is not allowed.");
    Cancel = true;
Return to top