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 change the WinForms GridGroupingControl text in GroupHeader and GroupFooter?

Platform: WinForms |
Control: GridGroupingControl
Tags: header, footer

Change the text

When loading the GridGroupingControl, the values of the header or footer will not be displayed because grid's underlying data source doesn't maintain the data of these headers and footer. So, we need to manually populate/show the values of GroupHeaders or Footers.


To show the GroupHeaders or GroupFooters, ShowGroupHeader and ShowGroupFooter properties will be used. QueryCellInfo event is used to display the needed text on these header/footer cells. The modified cell text can be retrieved through 'CurrentCellControlLostFocus' event.


In the given code sample, the global variables 'header' and 'footer' will be used to retrieve or display the content using QueryCellInfo and CurrentCellControlLostFocus events.


this.gridGroupingControl1.TopLevelGroupOptions.ShowGroupHeader = true;
this.gridGroupingControl1.TopLevelGroupOptions.ShowGroupFooter = true;
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
this.gridGroupingControl1.TableControl.CurrentCellControlLostFocus += TableControl_CurrentCellControlLostFocus;
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
    //assigning the GroupHeader text
    if(e.TableCellIdentity.TableCellType== GridTableCellType.GroupHeaderSectionCell )
        e.Style.Text = header;
    //assigning the GroupFooter text
    else if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupFooterSectionCell)
        e.Style.Text = footer;
void TableControl_CurrentCellControlLostFocus(object sender, ControlEventArgs e)
   GridTableControl table = (sender as GridTableControl);
    GridTableCellStyleInfo style = table.GetTableViewStyleInfo(table.CurrentCell.RowIndex, table.CurrentCell.ColIndex);
   //save the header text
    if (style.TableCellIdentity.TableCellType == GridTableCellType.GroupHeaderSectionCell)
        header = e.Control.Text;
    //save the footer text
    else if (style.TableCellIdentity.TableCellType == GridTableCellType.GroupFooterSectionCell)
        footer = e.Control.Text;


Me.gridGroupingControl1.TopLevelGroupOptions.ShowGroupHeader = True
Me.gridGroupingControl1.TopLevelGroupOptions.ShowGroupFooter = True
AddHandler gridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo
AddHandler Me.gridGroupingControl1.TableControl.CurrentCellControlLostFocus, AddressOf TableControl_CurrentCellControlLostFocus
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
    ‘assigning the GroupHeader text
    If e.TableCellIdentity.TableCellType= GridTableCellType.GroupHeaderSectionCell Then
          e.Style.Text = header
    ‘assigning the GroupFooter text
    ElseIf e.TableCellIdentity.TableCellType = GridTableCellType.GroupFooterSectionCell    Then
           e.Style.Text = footer
    End If
End Sub
Private Sub TableControl_CurrentCellControlLostFocus(ByVal sender As Object, ByVal e As ControlEventArgs)
    Dim table As GridTableControl = (TryCast(sender, GridTableControl))
    Dim style As GridTableCellStyleInfo = table.GetTableViewStyleInfo(table.CurrentCell.RowIndex, table.CurrentCell.ColIndex)
    ‘save the header text
    If style.TableCellIdentity.TableCellType = GridTableCellType.GroupHeaderSectionCell Then
        header = e.Control.Text
    ‘save the footer text
    ElseIf style.TableCellIdentity.TableCellType = GridTableCellType.GroupFooterSectionCell Then
        footer = e.Control.Text
    End If
End Sub



Show header and footer in GridGroupingControl


Change the text in header and footer

Reference link: https://help.syncfusion.com/windowsforms/gridgrouping/grouping#groupby-options

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