다음을 통해 공유


Chart.BeforeRightClick 이벤트

Chart 컨트롤을 마우스 오른쪽 단추로 클릭할 때 기본적인 오른쪽 클릭 동작 이전에 발생합니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel(Microsoft.Office.Tools.Excel.dll)

구문

‘선언
Event BeforeRightClick As ChartEvents_BeforeRightClickEventHandler
event ChartEvents_BeforeRightClickEventHandler BeforeRightClick

예제

다음 코드 예제에서는 차트를 마우스 오른쪽 단추로 클릭할 때 메시지 상자를 표시하는 BeforeRightClick 이벤트에 대한 처리기가 있는 Chart를 만듭니다. 또한 차트에서 오른쪽 클릭 동작을 수신하지 않도록 이벤트 처리기의 Cancel 매개 변수를 true로 설정합니다.

WithEvents RightClickChart As Microsoft.Office.Tools.Excel.Chart

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

    RightClickChart = Me.Controls.AddChart(Me.Range("D2", "H12"), _
        "RightClickChart")
    RightClickChart.SetSourceData(Me.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    RightClickChart.ChartType = Excel.XlChartType.xl3DColumn
End Sub

Sub RightClickChart_BeforeRightClick(ByRef Cancel As Boolean) _
    Handles RightClickChart.BeforeRightClick

    MsgBox("Right-clicking this chart is not allowed.")
    Cancel = True
End Sub
private void DisallowRightClicks()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");
    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.BeforeRightClick +=
        new Excel.ChartEvents_BeforeRightClickEventHandler(
        chart1_BeforeRightClick);
}

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

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

Chart 인터페이스

Microsoft.Office.Tools.Excel 네임스페이스