Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Apply a Filter to a View

In This Article

#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 });