Share via


ChartSheet.BeforeRightClick Event

Occurs when the Microsoft.Office.Tools.Excel.ChartSheet is right-clicked, before the default right-click action.

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

Syntax

'Declaration
Event BeforeRightClick As ChartEvents_BeforeRightClickEventHandler
event ChartEvents_BeforeRightClickEventHandler BeforeRightClick

Examples

The following code example demonstrates a handler for the BeforeRightClick event that displays a message box when the current Microsoft.Office.Tools.Excel.ChartSheet is right-clicked. The example also sets the Cancel parameter of the event handler to true so that the chart sheet does not receive the right click action.

Private Sub DisallowRightClicks()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    Me.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    Me.ChartType = Excel.XlChartType.xl3DColumn
End Sub 

Sub ChartSheet1_BeforeRightClick(ByRef Cancel As Boolean) _
    Handles Me.BeforeRightClick
    MsgBox("Right-clicking this chart sheet is not allowed.")
    Cancel = True 
End Sub
private void DisallowRightClicks()
{
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    this.ChartType = Excel.XlChartType.xl3DColumn;

    this.BeforeRightClick +=
        new Excel.ChartEvents_BeforeRightClickEventHandler(
        ChartSheet1_BeforeRightClick);
}

void ChartSheet1_BeforeRightClick(ref bool Cancel)
{
    MessageBox.Show("Right-clicking this chart sheet is not allowed.");
    Cancel = true;
}

.NET Framework Security

See Also

Reference

ChartSheet Interface

Microsoft.Office.Tools.Excel Namespace