Articles in this section

How to customize group caption summary appearance in WinForms GridGroupingControl?

Customize the group caption summary


In order to show the total item and total count of the caption summary in the group caption row with appearance customization, it can be handled by the following codes.

C#

GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor("Sum", SummaryType.DoubleAggregate, "Freight", "Total : {Sum:#}");
GridSummaryColumnDescriptor scd1 = new GridSummaryColumnDescriptor("Count", SummaryType.DoubleAggregate, "EmployeeID", "{Count:#} : items");
GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("Sum");
srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left;
srd.SummaryColumns.AddRange(new GridSummaryColumnDescriptor[] { scd, scd1 });
this.gridGroupingControl1.GetTableDescriptor("Orders").SummaryRows.Add(srd);
this.gridGroupingControl1.ChildGroupOptions.ShowCaptionSummaryCells = true;
this.gridGroupingControl1.ChildGroupOptions.ShowSummaries = false;
this.gridGroupingControl1.ChildGroupOptions.CaptionSummaryRow = "Sum";
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("CustomerID");
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{CategoryCaption}: {Category}";
this.gridGroupingControl1.TableDescriptor.Appearance.GroupCaptionSummaryCell.BackColor = Color.FromArgb(240, 241, 242);
this.gridGroupingControl1.Appearance.GroupCaptionCell.CellType = "Static";
this.gridGroupingControl1.Appearance.GroupCaptionCell.Borders.Top = new GridBorder(GridBorderStyle.None);

VB

Private scd As New GridSummaryColumnDescriptor("Sum", SummaryType.DoubleAggregate, "Freight", "Total : {Sum:#}")
Private scd1 As New GridSummaryColumnDescriptor("Count", SummaryType.DoubleAggregate, "EmployeeID", "{Count:#} : items")
Private srd As New GridSummaryRowDescriptor("Sum")
srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left
srd.SummaryColumns.AddRange(New GridSummaryColumnDescriptor() { scd, scd1 })
Me.gridGroupingControl1.GetTableDescriptor("Orders").SummaryRows.Add(srd)
Me.gridGroupingControl1.ChildGroupOptions.ShowCaptionSummaryCells = True
Me.gridGroupingControl1.ChildGroupOptions.ShowSummaries = False
Me.gridGroupingControl1.ChildGroupOptions.CaptionSummaryRow = "Sum"
Me.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("CustomerID")
Me.gridGroupingControl1.ChildGroupOptions.CaptionText = "{CategoryCaption}: {Category}"
Me.gridGroupingControl1.TableDescriptor.Appearance.GroupCaptionSummaryCell.BackColor = Color.FromArgb(240, 241, 242)
Me.gridGroupingControl1.Appearance.GroupCaptionCell.CellType = "Static"
Me.gridGroupingControl1.Appearance.GroupCaptionCell.Borders.Top = New GridBorder(GridBorderStyle.None)

The screenshot below illustrates the group caption summary appearance in GridGroupingControl.

Show the caption summary

Samples:

C#: Caption Summary

VB: Caption Summary

 

Reference Link: Summaries

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied