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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the group caption text in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl
Tags: grouping

Customize the group caption

By default, the grouped columns cell value will be displayed without any formatting in GroupCaptionRow.


To change the GroupCaptionText, use QueryCellStyleInfo event to change the cell value using TableCellIdentity.


void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
     if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null)
          GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow;
          string date = "";
          DateTime dt;
          if (e.Style.Text != null && DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8), out dt))
                date = dt.ToString("MMM-yyyy");
          e.Style.CellValue = String.Format("{0}: {1} Items.", date,            e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount());



Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
     If e.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell AndAlso e.TableCellIdentity.GroupedColumn IsNot Nothing Then
        Dim captionRow As GridCaptionRow = TryCast(e.TableCellIdentity.DisplayElement, GridCaptionRow)
        Dim [date] As String = ""
        Dim dt As DateTime
        If e.Style.Text IsNot Nothing AndAlso DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8), dt) Then
            [date] = dt.ToString("MMM-yyyy")
        End If
        e.Style.CellValue = [String].Format("{0}: {1} Items.", [date], e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount())
     End If
End Sub



Customize the group caption text


C#: CustomGroupCaptionText

VB: CustomGroupCaptionText

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/grouping#customizing-captiontext

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