How to hide a row based on cellvalue in WinForms GridGroupingControl?
Hide a row
In order to hide a particular row based on the cell value in the WinForms GridGroupingControl, QueryRowHeight can be used. Please refer to the code snippet below. The record can be gained by using the DisplayElement collection. Then the record’s value can be cached from the GetValue method.
The matched search text of the record can be set to zero using the Size property to hide the record.
C#
void TableModel_QueryRowHeight(object sender, GridRowColSizeEventArgs e)
{
if (e.Index >= gridGroupingControl1.TableControl.TopRowIndex)
{
if (gridGroupingControl1.Table.DisplayElements[e.Index] != null)
{
Element el = gridGroupingControl1.Table.DisplayElements[e.Index];
Record rec = el.GetRecord();
if (el.Kind == DisplayElementKind.Record &&
rec != null &&
rec.GetValue("FirstName").Equals("Mary")) // colindex and the respective text.
{
e.Size = 0;
e.Handled = true;
}
}
}
} VB
Private Sub TableModel_QueryRowHeight(ByVal sender As Object, ByVal e As GridRowColSizeEventArgs)
If e.Index >= gridGroupingControl1.TableControl.TopRowIndex Then
If gridGroupingControl1.Table.DisplayElements(e.Index) IsNot Nothing Then
Dim el As Element = gridGroupingControl1.Table.DisplayElements(e.Index)
Dim rec As Record = el.GetRecord()
If el.Kind = DisplayElementKind.Record AndAlso
rec IsNot Nothing AndAlso
rec.GetValue("City").Equals("London") Then ' colindex and the respective text.
e.Size = 0
e.Handled = True
End If
End If
End If
End SubThe screenshots below display the hiding of row based on the cell value.
Before

After

Samples:
C#: HideRow_CS
VB: HideRow_VB
Conclusion
I hope you
enjoyed learning about how to hide a row based on cellvalue in WinForms
GridGroupingControl.
You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!