共用方式為


Chart.SeriesChange 事件

會在 Chart 控制項資料點的值變更時發生。

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

語法

'宣告
Event SeriesChange As ChartEvents_SeriesChangeEventHandler
event ChartEvents_SeriesChangeEventHandler SeriesChange

範例

下列程式碼範例會建立 Chart,以及會在圖表資料點變更時將資料點框線設定為綠色的 SeriesChange 事件處理常式。

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

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

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

Sub SeriesChart_SeriesChange(ByVal SeriesIndex As Integer, _
    ByVal PointIndex As Integer) Handles SeriesChart.SeriesChange

    Dim series1 As Excel.Series = _
         CType(SeriesChart.SeriesCollection(SeriesIndex), _
         Excel.Series)
    Dim point1 As Excel.Point = _
        CType(series1.Points(PointIndex), Excel.Point)

    point1.Border.Color = _
            ColorTranslator.ToOle(Color.Green)
End Sub
Microsoft.Office.Tools.Excel.Chart seriesChart;

private void ChangePointColorWhenSeriesChange()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

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

    seriesChart.SeriesChange +=
        new Excel.ChartEvents_SeriesChangeEventHandler(
        seriesChart_SeriesChange);
}

void seriesChart_SeriesChange(int SeriesIndex, int PointIndex)
{
    Excel.Series series1 =
        (Excel.Series)seriesChart.SeriesCollection(SeriesIndex);
    Excel.Point point1 = (Excel.Point)series1.Points(PointIndex);

    point1.Border.Color =
        ColorTranslator.ToOle(Color.Green);
}

.NET Framework 安全性

請參閱

參考

Chart 介面

Microsoft.Office.Tools.Excel 命名空間