How to hide the summary row for specific value of the Grouped Column in WinForms ?
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.
Figure 1: No summary row for value 0
Conclusion
I hope you enjoyed learning about how to hide the summary row for specific value of the Grouped Column in WinForms.
You can refer to our WinForms DataGrid featuretour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinRT DataGrid 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