Chart.Calculate Event

Occurs after the Chart control plots new or changed data.

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

Syntax

'Declaration
Event Calculate As ChartEvents_CalculateEventHandler
event ChartEvents_CalculateEventHandler Calculate

Examples

The following code example creates a Chart with a handler for the Calculate event that displays a message box when the source data of the chart changes.

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

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

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

    ' This will raise the Calculate event.
    Me.Range("A1").Value2 = 11
End Sub

Sub CalculateChart_Calculate() Handles CalculateChart.Calculate
    MsgBox("The chart plotted new data.")
End Sub
private void DisplayWhenCalculated()
{
    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.Calculate +=
        new Excel.ChartEvents_CalculateEventHandler(
        chart1_Calculate);

    // This will raise the Calculate event.
    this.Range["A1", missing].Value2 = 11;
}

void chart1_Calculate()
{
    MessageBox.Show("The chart plotted new data.");
}

.NET Framework Security

See Also

Reference

Chart Interface

Microsoft.Office.Tools.Excel Namespace