How to: Apply a Filter to a View

Example 1

This example demonstrates how to assign a filter to a View using the ColumnView.ActiveFilterString property.

gridView1.ActiveFilterString = "([ProductID] = 1 OR [ProductID] = 3 " + 
  "OR [ProductID] > 10) AND [Discount] = 0";

Example 2

The following code demonstrates how to create the following filter criteria via the ColumnView.ActiveFilterCriteria property, using the GroupOperator and BinaryOperator objects:

"[Extension] = '.gif' OR [Extension] = '.png'"

using DevExpress.Data.Filtering;

CriteriaOperator expr1 = new BinaryOperator("Extension", ".gif");
CriteriaOperator expr2 = new BinaryOperator("Extension", ".png");
gridView1.ActiveFilterCriteria = GroupOperator.Or(new CriteriaOperator[] { expr1, expr2 });