Category / Section
How to show the caption text at end of the grid in WinForms GridGroupingControl?
2 mins read
Show the caption text
By default, there is no support for showing the Caption at the end of the Grid. In order to show the caption text at the end of the WinForms GridGroupingControl, GroupFooterSection can be used (which will be displayed at the end of the table) and cell value of Group Footer Section cell is assigned to CaptionText.
C#
//Display the GroupFooter cell
this.gridGroupingControl1.TopLevelGroupOptions.ShowGroupFooter = true;
//Set the caption text to be displayed
String CaptionText = this.gridGroupingControl1.TableDescriptor.Name + ":" + this.gridGroupingControl1.Table.Records.Count + " Items";
this.gridGroupingControl1.Appearance.GroupFooterSectionCell.CellValue = CaptionText;
//Disable the editing
this.gridGroupingControl1.Appearance.GroupFooterSectionCell.CellType = GridCellTypeName.Static;
//Set the height of the GroupCaption
this.gridGroupingControl1.TableOptions.GroupFooterSectionHeight = 20;
VB
'Display the GroupFooter cell
Me.gridGroupingControl1.TopLevelGroupOptions.ShowGroupFooter = True
'Set the caption text to be displayed
Dim CaptionText As String = Me.gridGroupingControl1.TableDescriptor.Name & ":" & Me.gridGroupingControl1.Table.Records.Count & " Items"
Me.gridGroupingControl1.Appearance.GroupFooterSectionCell.CellValue = CaptionText
'Disable the editing
Me.gridGroupingControl1.Appearance.GroupFooterSectionCell.CellType = GridCellTypeName.Static
'Set the height of the GroupCaption
Me.gridGroupingControl1.TableOptions.GroupFooterSectionHeight = 20
The
Screenshot below displays the caption text at the end of the grid.
Samples: