Xceed Chart for WinForms v4.4 Documentation
Welcome to Xceed Chart for WinForms v4.4 / Installation Instructions / Integrating into Windows Forms / ChartGridControl / Filtering the data series displayed by the grid

In This Topic
    Filtering the data series displayed by the grid
    In This Topic

    The data series edited by the grid can be controlled in two ways:

    • Use the IncludedSeries and ExcludedSeries properties of the underlying DataSeriesGrid. The following example will display only the Values and Labels data series of a line series.   

      VB.NET  
      chartGridControl1.IncludedSeries = DataSeriesMask.Values Or DataSeriesMask.Labels
      chartGridControl1.ExcludedSeries = DataSeriesMask.None
      C#  
      chartGridControl1.IncludedSeries = DataSeriesMask.Values | DataSeriesMask.Labels;
      chartGridControl1.ExcludedSeries = DataSeriesMask.None;

      For more information regarding data series filtering, please refer to the Basic Series Functionality topic. 

    • Override the DataSeriesGrid class. The following code example demonstrates this technique:

      VB.NET  
      ...
      ' override the DataSeriesGrid
      Public Class MyDataGrid
      Inherits DataSeriesGrid Public Sub New() End Sub ' override the GetDataSeries method and return only the series you want to edit in

      ' the order you want to edit them
      Public Overrides Function GetDataSeries(ByVal seriesBase As SeriesBase) As DataSeriesCollection

      ' for this example assume that the series is derived from Series
      Dim series As Series = CType(seriesBase, Series)

      Dim col As DataSeriesCollection = New DataSeriesCollection()

      ' add fill effects, values, labels - reorder (if needed) must be made here

      col.Add(series.Appearance.FillEffects)
      col.Add(series.Values)
      col.Add(series.Labels)

      ' !IMPORTANT - this method must return an aligned collection so force align if needed
      col.Align()

      Return col
      End Function
      End Class
      ...

      ' define a member to keep your class instance
      Public myGrid As MyDataGrid

      ...
      ' handle form load event
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
      ' create your datagrid derivative
      myGrid = New MyDataGrid()

      ' replace the data grid used by the ChartGridControl
      ChartGridControl1.DataSeriesGrid = myGrid

      ' bind to the chart control
      ChartGridControl1.ChartControl = m_ChartControl
      End Sub
      C#  

      ...
      // override the DataSeriesGrid
      public class MyDataGrid : DataSeriesGrid
      {
      public MyDataGrid() { }
      // override the GetDataSeries method and return only the series you want to edit in
      // the order you want to edit them
      public override DataSeriesCollection GetDataSeries(SeriesBase seriesBase)
      {
      // for this example assume that the series is derived from Series
      Series series = (Series)seriesBase;
      DataSeriesCollection col = new DataSeriesCollection();

      // add fill effects, values, labels - reorder (if needed) must be made here
      col.Add(series.Appearance.FillEffects);
      col.Add(series.Values);
      col.Add(series.Labels);

      // !IMPORTANT - this method must return an aligned collection so force align if needed
      col.Align();

      return col;
      }
      }
      ...
      // define a member to keep your class instance
      public MyDataGrid myGrid;
      ...
      // handle form load event
      private void Form1_Load(object sender, System.EventArgs e)
      {
      // create your datagrid derivative
      myGrid = new MyDataGrid();

      // replace the data grid used by the ChartGridControl
      ChartGridControl1.DataSeriesGrid = myGrid;

      // bind to the chart control
      ChartGridControl1.ChartControl = m_ChartControl;
      }

    Related Examples

    Windows Forms: Visual Interface Components\Chart Data Grid
    Windows Forms: Visual Interface Components\Customized Chart DataGrid

    See Also

    ChartGridControl