We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display the summary values of the WinForms GridGroupingControl in the essential chart?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: February 13, 2020
Tags: summaries, chart

Display summary values

The ranges and values of the Chart control are extracted from the values of the gridgroupingcontrol. In the sample, the minimum and maximum values are taken from the values in the group. When the groups or records change, the GroupedColumn_Changed and RecordValueChanged events are handled. An additional timer is added to delay the update slightly so that the summary value is available. The drawing of the Chart is done by the SetChartData method.


//Hooking the GroupedColumn changes and RecordValueChanged events in the Form_Load
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(GroupedColumns_Changed);
this.gridGroupingControl1.RecordValueChanged += new RecordValueChangedEventHandler(gridGroupingControl1_RecordValueChanged);
//Changes the Chart data
private void GroupedColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
//Need to delay the update slightly so the summary value is available
private Timer t = null;
private void gridGroupingControl1_RecordValueChanged(object sender, RecordValueChangedEventArgs e)
   if(t == null)
      t = new Timer();
      t.Interval = 20;
      t.Tick += new EventHandler(t_Tick);
private void t_Tick(object sender, EventArgs e)
   Timer t = sender as Timer;


'Hooking the GroupedColumn changes and RecordValueChanged events in the Form_Load
Private Me.gridGroupingControl1.TableDescriptor.GroupedColumns.Changed += New Syncfusion.Collections.ListPropertyChangedEventHandler(AddressOf GroupedColumns_Changed)
Private Me.gridGroupingControl1.RecordValueChanged += New RecordValueChangedEventHandler(AddressOf gridGroupingControl1_RecordValueChanged)
'Changes the Chart data
Private Sub GroupedColumns_Changed(ByVal sender As Object, ByVal e As Syncfusion.Collections.ListPropertyChangedEventArgs)
End Sub
'Need to delay the update slightly so the summary value is available
Private t As Timer = Nothing
Private Sub gridGroupingControl1_RecordValueChanged(ByVal sender As Object, ByVal e As RecordValueChangedEventArgs)
   If t Is Nothing Then
      t = New Timer()
      t.Interval = 20
      AddHandler t.Tick, AddressOf t_Tick
   End If
End Sub
Private Sub t_Tick(ByVal sender As Object, ByVal e As EventArgs)
   Dim t As Timer = TryCast(sender, Timer)
End Sub

SetChartData() method

In this method, the properties of the Chart are set. Based on the Summary values of the GridGroupingControl, the Chart is drawn.


private void SetChartData()
   int numPoints = this.gridGroupingControl1.Table.TopLevelGroup.Groups.Count;
      ChartSeries series = new ChartSeries();
      double yMax = double.MinValue;
      double yMin = double.MaxValue;
      double xMin = double.MaxValue;
      double xMax = double.MinValue;
      for(int j = 0; j < numPoints; j++)
         Group g = this.gridGroupingControl1.Table.TopLevelGroup.Groups[j];
         double x;
         double y;
         if(double.TryParse(g.Category.ToString(), System.Globalization.NumberStyles.Any, null, out x) && double.TryParse(GridEngine.GetSummaryText(g, this.scd), System.Globalization.NumberStyles.Any, null, out y))
            series.Points.Add(x, y);
            if(y < yMin)
               yMin = y;
               if(y > yMax)
                  yMax = y;
               if(x < xMin)
                  xMin = x;
               if(x > xMax)
                  xMax = x;
      this.chartControl1.Indexed = false;
      this.chartControl1.ZoomFactorX = 1;
      this.chartControl1.ZoomFactorY = 1;
      this.chartControl1.PrimaryXAxis.DrawGrid = false;
      this.chartControl1.PrimaryYAxis.DrawGrid = false;
      this.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
      this.chartControl1.PrimaryYAxis.Range.Max = yMax;
      this.chartControl1.PrimaryYAxis.Range.Min = yMin;
      this.chartControl1.PrimaryYAxis.Range.Interval = (yMax - yMin) / 4;
      this.chartControl1.PrimaryYAxis.Font = new Font(this.Font.Name, 8);
      this.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
      this.chartControl1.PrimaryXAxis.Range.Max = xMax;
      this.chartControl1.PrimaryXAxis.Range.Min = xMin;
      this.chartControl1.PrimaryXAxis.Range.Interval = 2;
      this.chartControl1.Legend.Visible = false;
      series.Type = ChartSeriesType.Line;
      series.Style.DisplayShadow = false;
   catch (Exception ex)


Private Sub SetChartData()
   Dim numPoints As Integer = Me.gridGroupingControl1.Table.TopLevelGroup.Groups.Count
      Dim series As New ChartSeries()
      Dim yMax As Double = Double.MinValue
      Dim yMin As Double = Double.MaxValue
      Dim xMin As Double = Double.MaxValue
      Dim xMax As Double = Double.MinValue
      For j As Integer = 0 To numPoints - 1
          Dim g As Group = Me.gridGroupingControl1.Table.TopLevelGroup.Groups(j)
          Dim x As Double
          Dim y As Double
          If Double.TryParse(g.Category.ToString(), System.Globalization.NumberStyles.Any, Nothing, x) AndAlso Double.TryParse(GridEngine.GetSummaryText(g, Me.scd), System.Globalization.NumberStyles.Any, Nothing, y) Then
             series.Points.Add(x, y)
             If y < yMin Then
      yMin = y
   End If
   If y > yMax Then
      yMax = y
   End If
   If x < xMin Then
      xMin = x
   End If
   If x > xMax Then
      xMax = x
   End If
          End If
      Next j
      Me.chartControl1.Indexed = False
      Me.chartControl1.ZoomFactorX = 1
      Me.chartControl1.ZoomFactorY = 1
      Me.chartControl1.PrimaryXAxis.DrawGrid = False
      Me.chartControl1.PrimaryYAxis.DrawGrid = False
      Me.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set
      Me.chartControl1.PrimaryYAxis.Range.Max = yMax
      Me.chartControl1.PrimaryYAxis.Range.Min = yMin
      Me.chartControl1.PrimaryYAxis.Range.Interval = (yMax - yMin) / 4
      Me.chartControl1.PrimaryYAxis.Font = New Font(Me.Font.Name, 8)
      Me.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set
      Me.chartControl1.PrimaryXAxis.Range.Max = xMax
      Me.chartControl1.PrimaryXAxis.Range.Min = xMin
      Me.chartControl1.PrimaryXAxis.Range.Interval = 2
      Me.chartControl1.Legend.Visible = False
      series.Type = ChartSeriesType.Line
      series.Style.DisplayShadow = False
   Catch ex As Exception
   End Try
End Sub

The following screenshot displays the summary value in the Chart.

Show summary values in chart


C#: GGCChart-C#1445073499.zip

VB: GGCChart-VB1929825338.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon