Category / Section
How to replace the filter bar cell text as empty instead of “(All)” in WinForms GridGroupingControl?
1 min read
Replace the filter bar cell text
In GridGroupingControl, filter bar cell text is “(All)” by default as in the following screenshot.
Figure 1: Filter bar cell text is “(All)” in Grid
To replace the filter bar cell text as empty instead of “(All)”, you can use the TableControlDrawCellDisplayText event. The following code example is used to set filter bar text as Empty.
C#
//Event hooking. this.gridGroupingControl1.TableControlDrawCellDisplayText += new GridTableControlDrawCellDisplayTextEventHandler(gridGroupingControl1_TableControlDrawCellDisplayText); void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e) { GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex); if(e.Inner.DisplayText == "(All)" && style.TableCellIdentity.TableCellType== GridTableCellType.FilterBarCell) { // restrict the filter bar display text, if it's '(All)'. e.Inner.Cancel = true; } }
VB
'Event hooking. Private Me.gridGroupingControl1.TableControlDrawCellDisplayText += New GridTableControlDrawCellDisplayTextEventHandler(AddressOf gridGroupingControl1_TableControlDrawCellDisplayText) Private Sub gridGroupingControl1_TableControlDrawCellDisplayText(ByVal sender As Object, ByVal e As GridTableControlDrawCellDisplayTextEventArgs) Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex) If e.Inner.DisplayText = "(All)" AndAlso style.TableCellIdentity.TableCellType= GridTableCellType.FilterBarCell Then ' restrict the filter bar display text, if it's '(All)'. e.Inner.Cancel = True End If End Sub
After removing “(All)” from filter bar cell text, the Grid is displayed as follows.
Figure 2: Filter bar cell text (All) removed
Samples: