How to hide the summary row for specific value of the grouped column in WinForms GridGroupingControl?
You can hide the summary row for a particular summary value by using the QueryRowHeight event in WinForms GridGroupingControl. 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;
}
}
}
}
}
AddHandler Me.gridGroupingControl1.TableModel.QueryRowHeight, AddressOf TableModel_QueryRowHeight
Private Sub TableModel_QueryRowHeight(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs)
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
End If
End If
End Sub
Figure 1: No summary row for value 0
Conclusion
I hope you enjoyed learning about how to hide the summary row of the grouped column in GridGroupingControl.
You can refer to our WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations WinForms GridGroupingControl documentation and how to quickly get started for configuration specifications. You can also explore our WinForms GridGroupingControl example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!