)
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 show the summary value of a summary row in caption row in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: January 12, 2018 |
Last Revised Date: December 23, 2019
Tags: summaries

Summaries

In order to show the summary value in group caption, customize the caption text format with name of GridSummaryRowDescriptor and name of GridSummaryColumnDescriptor.

C#

//To add summary.
GridSummaryColumnDescriptor summaryColumnDescriptor = new GridSummaryColumnDescriptor();
summaryColumnDescriptor.Name = "Category";
summaryColumnDescriptor.DataMember = "CategoryID";
summaryColumnDescriptor.Format = "{Average:#.00}";
summaryColumnDescriptor.SummaryType = SummaryType.DoubleAggregate;        
GridSummaryRowDescriptor summaryRowDescriptor = new GridSummaryRowDescriptor();
summaryRowDescriptor.Name = "Average of CategoryID column";           
summaryRowDescriptor.SummaryColumns.Add(summaryColumnDescriptor);
gridGroupingControl1.TableDescriptor.SummaryRows.Add(summaryRowDescriptor);            
this.gridGroupingControl1.TopLevelGroupOptions.ShowSummaries = false;
 
//To retrieve summaryrow name.
string summaryRowName = summaryRowDescriptor.Name;
//To retrieve summarycolumn name.
string summaryColumnName = summaryColumnDescriptor.Name;
//Setting caption text. 
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{Category} {RecordCount} Items at Average {" + summaryRowName + "." + summaryColumnName + "}" ;

 

VB

'To add summary.
Dim summaryColumnDesecriptor As New GridSummaryColumnDescriptor()
summaryColumnDesecriptor.Name = "Category"
summaryColumnDesecriptor.DataMember = "CategoryID"
summaryColumnDesecriptor.Format = "{Average:#.00}"
summaryColumnDesecriptor.SummaryType = SummaryType.DoubleAggregate
Dim summaryRowDescriptor As New GridSummaryRowDescriptor()
summaryRowDescriptor .Name = "Summary Row"
summaryRowDescriptor .SummaryColumns.Add(summaryColumnDescriptor)
gridGroupingControl1.TableDescriptor.SummaryRows.Add(summaryRowDescriptor)
Me.gridGroupingControl1.TopLevelGroupOptions.ShowSummaries = False
 
'To retrieve summaryrow name.
Dim summaryRowName As String = summaryRowDescriptor.Name
'To retrieve summarycolumn name.
Dim summaryColumnName As String = summaryColumnDescriptor.Name
'Setting caption text. 
Me.gridGroupingControl1.ChildGroupOptions.CaptionText = "{Category} {RecordCount} Items at Average {" & summaryRowName & "." & summaryColumnName & "}"

 

Screenshot

 Setting summary value in caption text

 

Samples:

C#: Retrieving SummaryValue_CS

VB: Retrieving SummaryValue_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/summaries

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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