Category / Section
How to filter the more than one field with specified criteria in WinForms GridGroupingControl?
1 min read
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
Samples:
C#: Filter more than one fields_CS
VB: Filter more than one fields_VB
Reference link: https://help.syncfusion.com/windowsforms/gridgrouping/filtering