Megosztás a következőn keresztül:


Chart.Calculate Event (2007 System)

Occurs after the Chart control plots new or changed data.

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

Syntax

'Declaration
Public Event Calculate As ChartEvents_CalculateEventHandler
'Usage
Dim instance As Chart 
Dim handler As ChartEvents_CalculateEventHandler 

AddHandler instance.Calculate, handler
public event ChartEvents_CalculateEventHandler Calculate
public:
 event ChartEvents_CalculateEventHandler^ Calculate {
    void add (ChartEvents_CalculateEventHandler^ value);
    void remove (ChartEvents_CalculateEventHandler^ value);
}
JScript does not support events.

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 Class

Chart Members

Microsoft.Office.Tools.Excel Namespace