共用方式為


ChartSheet.BeforeRightClick 事件 (2007 系統)

更新:2007 年 11 月

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

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

語法

Public Event BeforeRightClick As ChartEvents_BeforeRightClickEventHandler

Dim instance As ChartSheet
Dim handler As ChartEvents_BeforeRightClickEventHandler

AddHandler instance.BeforeRightClick, handler
public 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;
}

使用權限

請參閱

參考

ChartSheet 類別

ChartSheet 成員

Microsoft.Office.Tools.Excel 命名空間