ChartSheet.SeriesChange 事件
在 Microsoft.Office.Tools.Excel.ChartSheet 数据点的值更改时发生。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Event SeriesChange As ChartEvents_SeriesChangeEventHandler
event ChartEvents_SeriesChangeEventHandler SeriesChange
示例
下面的代码示例演示 SeriesChange 事件的一个处理程序,该处理程序在当前 Microsoft.Office.Tools.Excel.ChartSheet 的数据点更改时将该点的边框颜色设置为绿色。
Private Sub ChangePointColorWhenSeriesChange()
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_SeriesChange(ByVal SeriesIndex As Integer, _
ByVal PointIndex As Integer) Handles Me.SeriesChange
Dim series1 As Excel.Series = _
CType(Me.SeriesCollection(SeriesIndex), Excel.Series)
Dim point1 As Excel.Point = _
CType(series1.Points(PointIndex), Excel.Point)
point1.Border.Color = _
ColorTranslator.ToOle(Color.Green)
End Sub
private void ChangePointColorWhenSeriesChange()
{
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.SeriesChange +=
new Excel.ChartEvents_SeriesChangeEventHandler(
ChartSheet1_SeriesChange);
}
void ChartSheet1_SeriesChange(int SeriesIndex, int PointIndex)
{
Excel.Series series1 =
(Excel.Series)this.SeriesCollection(SeriesIndex);
Excel.Point point1 = (Excel.Point)series1.Points(PointIndex);
point1.Border.Color =
ColorTranslator.ToOle(Color.Green);
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。