)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the summary column for specific rows in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 20, 2015 |
Last Revised Date: February 13, 2020
Tags: summaries

Customize the summary row or column

To customize the summary row descriptor to summarize the specific rows, you can use the QueryCellStyleInfo. The reported scenario is achieved by customizing the SummaryFieldCell.

C#

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    switch (e.TableCellIdentity.TableCellType)
    {
        case GridTableCellType.SummaryFieldCell:
                {
                    if(e.TableCellIdentity.SummaryColumn.Name == "Data1")
                    {
                       e.Style.CellType = GridCellTypeName.FormulaCell;
                       e.Style.CellValue = "=SUM(B2:B5)"; //To summarize specific rows(First three rows)
                    }
                    break;
                }
     }
}

VB

Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
   Select Case e.TableCellIdentity.TableCellType
      Case GridTableCellType.SummaryFieldCell
               If e.TableCellIdentity.SummaryColumn.Name = "Data1" Then
                  e.Style.CellType = GridCellTypeName.FormulaCell
                  e.Style.CellValue = "=SUM(B2:B5)" 'To summarize specific rows(First three rows)
               End If
      Exit Select
   End Select
End Sub

In the sample, Summary is calculated for first three rows.

Summary row calculated for first three rows

Figure 1: Summary calculated for first three rows

Samples:

C#: SummaryRow_Customization_C#

VB: SummaryRow_Customization_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon