)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to hide the filter bar buttons in the GridDynamicFilter in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: August 8, 2016 |
Last Revised Date: December 24, 2019
Tags: filtering

Dynamic filter

The grid does not have built-in support to hide the filter bar buttons in the GridDynamicFilter. It can be achieved by creating the custom cell renderer and cell model. In the custom cell renderer, we have to override the OnLayout method.

For example, in the below code snippet, created the custom cell model and renderer, then assigned the model into the cell type to avoid the filter bar buttons.

Creating Cell Model

C#

public class GridTableFilterCellModelAdv : GridTableFilterBarExtCellModel
{
  public GridTableFilterCellModelAdv(GridModel grid): base(grid)
  {
    this.SelectAllText = string.Empty;
  }
  public override GridCellRendererBase CreateRenderer(GridControlBase control)
  {
    return new GridTableFilterCellRendererAdv(control, this);
  }
}

 

VB

Public Class GridTableFilterCellModelAdv
  Inherits GridTableFilterBarExtCellModel
  Public Sub New(ByVal grid As GridModel)
    MyBase.New(grid)
      Me.SelectAllText = String.Empty
  End Sub
  Public Overrides Function CreateRenderer(ByVal control As GridControlBase) As GridCellRendererBase
    Return New GridTableFilterCellRendererAdv(control, Me)
  End Function
End Class

 

Creating Cell Renderer

C#

public class GridTableFilterCellRendererAdv : GridTableFilterBarExtCellRenderer
{
  public GridTableFilterCellRendererAdv(GridControlBase grid, GridCellModelBase   cellModel): base(grid, cellModel)
  {
 
  }
  protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo   style, Rectangle innerBounds, Rectangle[] buttonsBounds)
  {
      return new Rectangle(innerBounds.X, innerBounds.Y, innerBounds.Width,    innerBounds.Height);
  }
}

 

VB

Public Class GridTableFilterCellRendererAdv
 Inherits GridTableFilterBarExtCellRenderer
  Public Sub New(ByVal grid As GridControlBase, ByVal cellModel As GridCellModelBase)
   MyBase.New(grid, cellModel)
  End Sub
 
  Protected Overrides Function OnLayout(ByVal rowIndex As Integer, ByVal colIndex As Integer, ByVal style As GridStyleInfo, ByVal innerBounds As Rectangle, ByVal buttonsBounds() As Rectangle) As Rectangle
  Return New Rectangle(innerBounds.X, innerBounds.Y, innerBounds.Width, innerBounds.Height)
  End Function
End Class

 

Adding CellModel and Assigning CellType

C#

this.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = true;
for (int i = 0; i < this.gridGroupingControl1.TableDescriptor.Columns.Count; i++)
{
  this.gridGroupingControl1.TableDescriptor.Columns[i].AllowFilter = true;
}
this.gridGroupingControl1.TopLevelGroupOptions.ShowCaption = false;
GridTableFilterBarExtCellModel filterBarExtCell = new GridTableFilterCellModelAdv(this.gridGroupingControl1.TableModel);
this.gridGroupingControl1.TableModel.CellModels.Add("DynamicFilter", filterBarExtCell);
this.gridGroupingControl1.TableDescriptor.Appearance.FilterBarCell.CellType = "DynamicFilter";

 

VB

Me.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = True
For i As Integer = 0 To Me.gridGroupingControl1.TableDescriptor.Columns.Count - 1
  Me.gridGroupingControl1.TableDescriptor.Columns(i).AllowFilter = True
Next i
Me.gridGroupingControl1.TopLevelGroupOptions.ShowCaption = False
Dim filterBarExtCell As GridTableFilterBarExtCellModel = New GridTableFilterCellModelAdv(Me.gridGroupingControl1.TableModel)
Me.gridGroupingControl1.TableModel.CellModels.Add("DynamicFilter", filterBarExtCell)
Me.gridGroupingControl1.TableDescriptor.Appearance.FilterBarCell.CellType = "DynamicFilter"

 

ScreenShot

Hide the filter bar buttons

Samples:

C#: FilterBar_CS

VB: FilterBar_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/filtering#dynamic-filter

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon