Skip to main content
A newer version of this page is available. .

How to: Apply a Filter to a Column

  • 2 minutes to read

Example 1

The following code selects records whose shipping country names start with ‘F’. The required filter is created using a ColumnFilterInfo object. It’s then assigned to the GridColumn.FilterInfo property.

using DevExpress.XtraGrid.Columns;

gridView1.Columns["ShipCountry"].FilterInfo = 
  new ColumnFilterInfo("[ShipCountry] LIKE 'F%'");

Example 2

The following code shows how to add a filter condition to a View via its ColumnView.ActiveFilter object. The filter condition selects records whose CategoryName fields start with ‘c’.

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Columns;
//...
ColumnView view = gridView1;
view.ActiveFilter.Add(view.Columns["CategoryName"], 
  new ColumnFilterInfo("[CategoryName] Like 'c%'", ""));

Example 3

The following code shows how to add a filter condition to a View via its ColumnView.ActiveFilter object. The filter condition selects records which contain the values “Produce” or “Seafood” in the CategoryName column.

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Columns;
//...
ColumnView view = gridView1;
ViewColumnFilterInfo viewFilterInfo = new ViewColumnFilterInfo(view.Columns["CategoryName"], 
  new ColumnFilterInfo("[CategoryName] = 'Produce' OR [CategoryName] = 'Seafood'", ""));
view.ActiveFilter.Add(viewFilterInfo);

Example 4

The following example selects records that contain a null value in the ‘Region’ field.

colRegion.FilterInfo = new DevExpress.XtraGrid.Columns.ColumnFilterInfo("[Region] IS NULL");