$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
GridView Windows Forms Control
Filtering data in GridView in C# Windows Forms applications
Home > WinForms UI Controls > User Manual > Data Grid Filter Setting in C#

C# for Grid Filtering in Windows Forms

The data filtering function support is built in the Data Grid Control. It allows users process data filtering in any columns. When users click in the filter cell, the cell editor will be open and will allow users set the filter condition. When clicking the filtering icon in the filter cell, a menu will be open and provide filter conditions including greater than, contains, less than, equals to, and more. Developers can also customize the filtering features in C# code in Windows Forms projects.

How to Use GridView FilterDescriptors

The Kettic GridView .NET Component provides the FilterDescriptors property to hold filters descriptors for filtering grid data. This FilterDescriptors property is included in the GridViewTemplate of the C# Class for MasterTemplate instance. The significant C# class includes:
  • FilterDescriptor, this C# class is used to determine the expressions for grid data filtering and is able to implement grid filtering name, filtering operator and value.
  • CompositeFilterDescriptor, this C# class is a collection which stores various filtering descriptors and is able to create complex filtering expressions for C#.NET project.
The following is the C# code that demonstrates how to use the filer descriptor for .NET Windows Forms applications.

FilterDescriptor filter = new FilterDescriptor();
filter.PropertyName = "ProductName";
filter.Operator = FilterOperator.Contains;
filter.Value = "Computer";
filter.IsFilterEditor = true;

Properties of the FilterDescriptor for GridView

The FilterDescriptor C# class has various properties for the users to perform the grid data filtering operation.
  • PropertyName, this property is used to determine the property that values will be filtered.
  • Operator, this is a property that determines the operator type. The values available include, Like, NotLike, LessThanOrEqualTo, EqualTo, NotEqualTo, GreaterThanOrEqualTo, GreaterThan, StartsWith, EndsWith, Contains, NotContains.
  • Value, this property is used to determine the grid data being compared against

How to Create a Filter Descriptor in C#

The Kettic GridView offers FilterDescriptor property to each grid data column to assign a FilterDescriptor object. When a new descriptor is added to the collection, the grid data will be filtered automatically based on it. The following C# code shows how to assign a filtering descriptor object.

FilterDescriptor filter1 = new FilterDescriptor();
filter1.Operator = FilterOperator.Contains;
filter1.Value = "Computer";
filter1.IsFilterEditor = true;
this.ketticGridView1.Columns["ProductName"].FilterDescriptor = filter1;

How to Create Multiple Filters in C#

To set a variety of filters to GridView in C#.NET projects, we can use the C# code as following.
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls