Back to Devexpress

SeriesCollection.IndexOf(Series) Method

corelibraries-devexpress-dot-xtracharts-dot-seriescollection-dot-indexof-x28-devexpress-dot-xtracharts-dot-series-x29.md

latest5.1 KB
Original Source

SeriesCollection.IndexOf(Series) Method

Returns the specified object’s position within the collection.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public int IndexOf(
    Series series
)
vb
Public Function IndexOf(
    series As Series
) As Integer

Parameters

NameTypeDescription
seriesSeries

A Series object to locate in the collection.

|

Returns

TypeDescription
Int32

A zero-based integer which represents the object’s position within the collection. -1 if the object doesn’t belong to the collection.

|

Remarks

This method scans the collection starting from the first element and returns the index of the first matching element found.

The following code snippets (auto-collected from DevExpress Examples) contain references to the IndexOf(Series) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-charts-show-chart-legend-with-markers-in-separate-control/CS/Form1.cs#L77

csharp
{
    gridView1.FocusedRowHandle = gridView1.GetRowHandle(chart.Series.IndexOf(((Series)e.Object)));
}

asp-net-web-forms-web-chart-control-create-drill-down-chart/CS/DrillDownChart/WebForm1.aspx.cs#L52

csharp
if (e.States.Last().Parameters.TryGetValue("ProductCategory", out categoryValue)) {
    int seriesIndex = WebChartControl1.Series.IndexOf(WebChartControl1.Series[(string)categoryValue]);
    int colorIndex = seriesIndex % WebChartControl1.PaletteRepository[WebChartControl1.PaletteName].Count + 1;

winforms-chart-create-custom-legend-radio-buttons-to-control-visibility-of-a-chart-series/CS/MainForm.cs#L67

csharp
Color GetSeriesColor(Series series, ChartControl chartControl) {
    int seriesIndex = chartControl.Series.IndexOf(series);
    string paletteName = chartControl.PaletteName;

winforms-charts-show-chart-legend-with-markers-in-separate-control/VB/Form1.vb#L72

vb
If e.HitInfo.InSeries Then
    gridView1.FocusedRowHandle = gridView1.GetRowHandle(chart.Series.IndexOf(CType(e.Object, Series)))
End If

asp-net-web-forms-web-chart-control-create-drill-down-chart/VB/DrillDownChart/WebForm1.aspx.vb#L51

vb
If e.States.Last().Parameters.TryGetValue("ProductCategory", categoryValue) Then
    Dim seriesIndex As Integer = WebChartControl1.Series.IndexOf(WebChartControl1.Series(DirectCast(categoryValue, String)))
    Dim colorIndex As Integer = seriesIndex Mod WebChartControl1.PaletteRepository(WebChartControl1.PaletteName).Count + 1

winforms-chart-create-custom-legend-radio-buttons-to-control-visibility-of-a-chart-series/VB/MainForm.vb#L78

vb
Private Function GetSeriesColor(ByVal series As Series, ByVal chartControl As ChartControl) As Color
    Dim seriesIndex As Integer = chartControl.Series.IndexOf(series)
    Dim paletteName As String = chartControl.PaletteName

See Also

SeriesCollection Class

SeriesCollection Members

DevExpress.XtraCharts Namespace