)
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 filter the more than one field with specified criteria in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: May 18, 2016 |
Last Revised Date: February 12, 2020
Tags: filtering

Filtering

As per filtering architecture, the filtering performs based on the previous result of the filtering. In order to filter more than one fields, the expression can be added to RecordFilterDescriptorCollection instead of using the FilterCondition. In this example, this expression will filter the columns which are all not equal to the value 4.

C#

private void btnFilter_Click(object sender, EventArgs e)
{
   Filter();
}
 
public void Filter()
{
   this.gridGroupingControl1.TableDescriptor.RecordFilters.Clear();
   string Expression = string.Empty;
   if (checkBox1.Checked)
   {
      Expression = "[Col1] <> 4";
   }
   if (checkBox2.Checked)
   {
      if (checkBox1.Checked)
      {
         Expression += "OR [Col2] <> 4";
      }
      else
      {
         Expression = "[Col2]<>4";
      }
   }
   if (checkBox3.Checked)
   {
      Expression = "[Col3] <> 4";
      if (checkBox1.Checked)
      {
         Expression += "OR [Col1] <> 4";
      }
      if (checkBox2.Checked)
      {
         Expression += "OR [Col2] <> 4";
      }
   }
   this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(Expression);
}

VB

Private Sub btnFilter_Click(ByVal sender As Object, ByVal e As EventArgs)
   Filter()
End Sub
 
Public Sub Filter()
    Me.gridGroupingControl1.TableDescriptor.RecordFilters.Clear()
    Dim Expression As String = String.Empty
    If checkBox1.Checked Then
        Expression = "[Col1] <> 4"
    End If
    If checkBox2.Checked Then
        If checkBox1.Checked Then
          Expression &= "OR [Col2] <> 4"
       Else
          Expression = "[Col2]<>4"
       End If
    End If
    If checkBox3.Checked Then
       Expression = "[Col3] <> 4"
       If checkBox1.Checked Then
          Expression &= "OR [Col1] <> 4"
       End If
       If checkBox2.Checked Then
          Expression &= "OR [Col2] <> 4"
       End If
    End If
    Me.gridGroupingControl1.TableDescriptor.RecordFilters.Add(Expression)
End Sub

Show filter more than one fields

Show filter more than one fields while choosing specific columns

Samples:

C#: Filter more than one fields_CS

VB: Filter more than one fields_VB

Reference link: https://help.syncfusion.com/windowsforms/gridgrouping/filtering

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