[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Collapse]Filtering and Searching
    [Expand]Drop-down Filter
     Automatic Filter Row
     Filter Editor
     Filter Elements
    [Collapse]Filtering in Code
      Filter Expressions
      Allowed Filters
      Filter Modes and Custom Filtering
     Predefined Filters
     Data Analysis Filters
     Conditional Formatting Filters
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Filtering in Code

The GridControl allows you to apply filters in the UI and in code. This topic explains how to apply filters in code.

Refer to the Filtering topic for information on how to apply a filter in the UI.

Expanded Apply Filters

Use the following approaches to apply a filter in code:

  • Assign a filter string to the DataControlBase.FilterString property. Refer to the Filter Expressions and Criteria Language Syntax topics for information on supported syntax.

  • Create a CriteriaOperator object or its descendant that represents a filter expression and assign the created object to the DataControlBase.FilterCriteria property. Refer to the Criteria Operators topic for information on supported syntax.

The GridControl raises the DataControlBase.FilterChanged event when a filter is applied.

If the GridControl has a column filter, you can apply a filter to another column without resetting the existing filter. Pass a filter string or a CriteriaOperator to the DataControlBase.MergeColumnFilters method. This method uses the AND operator to combine filters for different columns.

Use the column's ColumnBase.IsFiltered property to identify whether a filter is applied to the column. The DataControlBase.GetColumnFilterCriteria and DataControlBase.GetColumnFilterString methods allow you to obtain the column's filter.

Users can modify filters specified by the DataControlBase.FilterCriteria and DataControlBase.FilterString properties. Use the DataControlBase.FixedFilter property to specify filter criteria that cannot be modified.

Data Analysis Filters

The GridControl allows you to apply the following Data Analysis Filters:

  • Top N
  • Bottom N
  • Above Average
  • Below Average
  • Unique
  • Duplicate

Use the DataControlBase.FilterString property to apply these filters in code:

You can also use the DataControlBase.FilterCriteria property:

Conditional Formatting Filters

The GridControl allows you to apply Conditional Formatting Filters. These filters are based on the conditional formats specified in the GridControl.

Here is the XAML code that specifies a conditional format:

The code sample below applies a conditional formatting filter:

Expanded Clear Filters

Use the following approaches to clear filters:

Expanded See Also

Is this topic helpful?​​​​​​​