[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
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Collapse]Filtering and Searching
    [Expand]Drop-down Filter
     Automatic Filter Row
     Filter Editor
     Filter Elements
    [Expand]Filtering in Code
     Predefined Filters
     Data Analysis Filters
     Conditional Formatting Filters
    [Expand]Search
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [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
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Conditional Formatting Filters

The GridControl allows you to specify Conditional Formatting rules and apply filters based on these rules:

Expanded Specify Conditional Formatting Rules

Use the TableView.FormatConditions / TreeListView.FormatConditions property to define conditional formatting rules:

Expanded Apply Conditional Formatting Filters

Filter Editor

Select conditional formatting filters in the Filter Editor:

Excel-style Drop-down Filter

Select conditional formatting filters in the Excel-style Drop-down Filter:

Format Condition Filter Element

Select conditional formatting filters in the FormatConditionFilterElement:

Add a FormatConditionFilterElement to the markup and specify the target GridControl and a column. The filter element lists all available conditional formats for the specified column:

In Code

Specify a filter string or filter criteria in code. The GridControl finds a corresponding conditional format rule and applies a filter that is based on this rule.

Note

If you specified a conditional formatting filter and then decided to change a conditional format on which the filter is based, the GridControl does not apply the filter. Change the filter to make it correspond to the changed conditional format.

The code sample below applies a filter that is based on the

<dxg:TopBottomRuleFormatCondition FieldName="UnitPrice" Rule="BelowAverage" PredefinedFormatName="YellowFillWithDarkYellowText" />

conditional format:

The following code sample applies a filter that is based on the

<dxg:FormatCondition FieldName="Quantity" ValueRule="LessOrEqual" Value1="5" PredefinedFormatName="BoldText" />

conditional format:

Tip

To build a filter string, you can apply a filter to the GridControl's in UI, and then obtain the filter string with the DataControlBase.FilterString property.

The following code samples demonstrate how to apply conditional formatting filters:

If a conditional format is applied to the entire row (see FormatConditionBase.ApplyToRow), you should specify a column to which you want to apply a conditional formatting filter.

The code sample below applies a filter that is based on the

<dxg:FormatCondition FieldName="Discount" ValueRule="Greater" Value1="0" PredefinedFormatName="GreenFillWithDarkGreenText" ApplyToRow="True" />

conditional format to the Country column. The first parameter is a filtered column's name and the second is a conditional format's field name:

 

If an expression condition is applied to the entire row and it does not have a field name, specify [] as the second parameter.

The code sample below applies a filter that is based on the

<dxg:FormatCondition Expression="Contains([Country], 'Sw')" PredefinedFormatName="ItalicText" ApplyToRow="True" />

conditional format to the Country column:

Expanded Limitations

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