How to show the summary value of a summary row in caption row in WinForms GridGroupingControl?
Summaries
In order to
show the summary value in group caption in WinForms GridGroupingControl, 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 & "}"
The below screenshot illustrates the summary value in the caption text
Samples:
C#: Retrieving SummaryValue_CS
VB: Retrieving SummaryValue_VB
Reference Link: Summaries
Conclusion
I hope you enjoyed learning about how to show the summary value of a summary row in caption row in WinForms GridGroupingControl.
You can refer to our WinForms GridGroupingControl page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!