Category / Section
How to add a filterbar to all the columns including child table in WinForms GridGroupingControl?
1 min read
Column filter
The Filter bar can be enabled for all the columns of all the tables by setting the AllowFilter property of the GridColumnDescriptor for each and every table of the grid. In the following code example, the filter bar is added to all columns of the table.
C#
this.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = true; this.gridGroupingControl1.ChildGroupOptions.ShowFilterBar = true; this.gridGroupingControl1.NestedTableGroupOptions.ShowFilterBar = true; //Add filter bar to all the parent columns. foreach (GridColumnDescriptor parentColumn in this.gridGroupingControl1.TableDescriptor.Columns) { parentColumn.AllowFilter = true; } //Add filter bar to all the child columns. foreach (GridColumnDescriptor childcolumn in this.gridGroupingControl1.GetTableDescriptor("MyChildTable").Columns) { childcolumn.AllowFilter = true; } //Add filter bar to all the grandchild columns. foreach (GridColumnDescriptor grandChildColumn in this.gridGroupingControl1.GetTableDescriptor("MyGrandChildTable").Columns) { grandChildColumn.AllowFilter = true; }
VB
Me.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = True Me.gridGroupingControl1.ChildGroupOptions.ShowFilterBar = True Me.gridGroupingControl1.NestedTableGroupOptions.ShowFilterBar = True 'Add filter bar to all the parent columns. For Each parentColumn As GridColumnDescriptor In Me.gridGroupingControl1.TableDescriptor.Columns parentColumn.AllowFilter = True Next parentColumn 'Add filter bar to all the child columns. For Each childcolumn As GridColumnDescriptor In Me.gridGroupingControl1.GetTableDescriptor("MyChildTable").Columns childcolumn.AllowFilter = True Next childcolumn 'Add filter bar to all the grandchild columns. For Each grandChildColumn As GridColumnDescriptor In Me.gridGroupingControl1.GetTableDescriptor("MyGrandChildTable").Columns grandChildColumn.AllowFilter = True Next grandChildColumn
After applying the properties, the filter bar is shown as follows.
Figure 1: Output
Samples:
C#: Column filter
VB: Column filter