)
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 option from filter bar dropdown list in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: October 17, 2014 |
Last Revised Date: December 23, 2019

Hide the custom option

To remove the (Custom….) option from the FilterBar dropdown list, you need to customize GridListFilterBarCellRenderer using TableControlCurrentCellShowingDropDown, TableControlCurrentCellCloseDropDown events.

C#

private void gridGroupingControl1_TableControlCurrentCellCloseDropDown(object sender, GridTableControlPopupClosedEventArgs e) 
{    GridCurrentCell cc = e.TableControl.CurrentCell;    if ((cc.Renderer.GetType() == GridListFilterBarCellRenderer)) 
    {       GridListFilterBarCellRenderer renderer = ((GridListFilterBarCellRenderer)(cc.Renderer));       if (((renderer.ListControlPart.SelectedIndex >= 1)                         && (renderer.ListControlPart.SelectedIndex                         <= (renderer.ListControlPart.Items.Count - 1)))) 
       {           renderer.ListControlPart.SelectedIndex = (renderer.ListControlPart.SelectedIndex + 1);       }    }}
private void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e) 
{    GridCurrentCell cc = e.TableControl.CurrentCell;    if ((cc.Renderer.GetType() == GridListFilterBarCellRenderer)) 
    {        GridListFilterBarCellRenderer renderer = ((GridListFilterBarCellRenderer)(cc.Renderer));        GridTableCellStyleInfo tableStyleInfo = ((GridTableCellStyleInfo)(renderer.StyleInfo));        renderer.ListControlPart.Items.RemoveAt(1);    }}

 

VB:

Private Sub gridGroupingControl1_TableControlCurrentCellCloseDropDown(ByVal sender As ObjectByVal As GridTableControlPopupClosedEventArgs)
     Dim cc As GridCurrentCell e.TableControl.CurrentCell
     If (TypeOf cc.Renderer Is GridListFilterBarCellRenderer) Then
        Dim renderer As GridListFilterBarCellRenderer = CType(cc.Renderer,GridListFilterBarCellRenderer)
        If ((renderer.ListControlPart.SelectedIndex >1)  _
           AndAlso (renderer.ListControlPart.SelectedIndex  _
           <(renderer.ListControlPart.Items.Count - 1))) Then
           renderer.ListControlPart.SelectedIndex (renderer.ListControlPart.SelectedIndex + 1)
        End If
     End If
End Sub


Private Sub gridGroupingControl1_TableControlCurrentCellShowingDropDown(ByVal sender As ObjectByVal As GridTableControlCurrentCellShowingDropDownEventArgs)
     Dim cc As GridCurrentCell e.TableControl.CurrentCell
     If (TypeOf cc.Renderer Is GridListFilterBarCellRenderer) Then
        Dim renderer As GridListFilterBarCellRenderer = CType(cc.Renderer,GridListFilterBarCellRenderer)
        Dim tableStyleInfo As GridTableCellStyleInfo = CType(renderer.StyleInfo,GridTableCellStyleInfo)
        renderer.ListControlPart.Items.RemoveAt(1)
     End If
End Sub

 

Sample:

http://www.syncfusion.com/downloads/support/directtrac/general/HidingOption_FilterBar-682653859.zip

 

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