Articles in this section
Category / Section

How to replace the filter bar cell text as empty instead of “(All)” in WinForms GridGroupingControl?

2 mins read

Replace the filter bar cell text


In WinForms GridGroupingControl, filter bar cell text is “(All)” by default as in the following screenshot.


Filter bar cell text is All in Grid


     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.


//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;
   }
}
'Event hooking
AddHandler Me.gridGroupingControl1.TableControlDrawCellDisplayText, AddressOf gridGroupingControl1_TableControlDrawCellDisplayText

Private Sub gridGroupingControl1_TableControlDrawCellDisplayText(sender As Object, 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 the filter bar cell text, the Grid is displayed as follows.


Show filter bar cell text All is removed

   
 Figure
2: Filter bar cell text (All) removed


Samples:

C#: Remove_FilterBarText_C#

VB: Remove_FilterBarText_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied