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 hide the summary row for specific value of the Grouped Column?

Platform: WinForms |
Control: GridGroupingControl
Tags: summary, hiding

You can hide the summary row for a particular summary value by using the QueryRowHeight event. Using this event, you can set the row height as 0 to hide the row of the grouped columns.

In the following code example, set the particular summary value as 0. When the summary value is zero, then the summary row is hidden in the Grid of the grouped columns.

C#

this.gridGroupingControl1.TableModel.QueryRowHeight += new Syncfusion.Windows.Forms.Grid.GridRowColSizeEventHandler(TableModel_QueryRowHeight); 
private void TableModel_QueryRowHeight(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
{
    Element element = gridGroupingControl1.Table.NestedDisplayElements[e.Index];
    if (element != null && element.Kind == DisplayElementKind.Summary)
    {
        GridSummaryRow sr = element as GridSummaryRow;
        if (sr != null)
        {
            foreach (GridSummaryColumnDescriptor scd in sr.SummaryRowDescriptor.SummaryColumns)
            {
                //Getting the value from Summary Row
                string result = GridEngine.GetSummaryText(sr.ParentGroup, scd);
 
                //checking whether result is 0
                if (result == "0")
                {
                    //Setting the RowHeight as 0(Hiding)
                    e.Size = 0;
                    e.Handled = true;
                }
            }
        }
    }
}

VB

AddHandler gridGroupingControl1.TableModel.QueryRowHeight, AddressOf TableModel_QueryRowHeight
private void TableModel_QueryRowHeight(Object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
  Dim element As Element = gridGroupingControl1.Table.NestedDisplayElements(e.Index)
  If element IsNot Nothing AndAlso element.Kind = DisplayElementKind.Summary Then
    Dim sr As GridSummaryRow = TryCast(element, GridSummaryRow)
    If sr IsNot Nothing Then
      For Each scd As GridSummaryColumnDescriptor In sr.SummaryRowDescriptor.SummaryColumns
        'Getting the value from Summary Row
        Dim result As String = GridEngine.GetSummaryText(sr.ParentGroup, scd)
          'checking whether result is 0
          If result = "0" Then
            'Setting the RowHeight as 0(Hiding)
              e.Size = 0
              e.Handled = True
          End If
      Next scd
    End If
  End If

After applying the properties, the Grid is displayed as follows.

C:\Users\venkatesh s\Desktop\image.png

Figure 1: No summary row for value 0

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