共用方式為


ChartSheet.BeforeRightClick 事件

會在 Microsoft.Office.Tools.Excel.ChartSheet 上按一下滑鼠右鍵時發生 (在預設滑鼠右鍵動作執行之前)。

命名空間:  Microsoft.Office.Tools.Excel
組件:   Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
Event BeforeRightClick As ChartEvents_BeforeRightClickEventHandler
event ChartEvents_BeforeRightClickEventHandler BeforeRightClick

範例

下列程式碼範例示範 BeforeRightClick 事件的處理常式,這個處理常式在目前的 Microsoft.Office.Tools.Excel.ChartSheet 上按一下滑鼠右鍵時會顯示訊息方塊。這個範例也會將事件處理常式的 Cancel 參數設定為 true,使圖表不會接收到滑鼠右鍵的動作。

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 安全性

請參閱

參考

ChartSheet 介面

Microsoft.Office.Tools.Excel 命名空間