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

FilterControl Class

A filter editor control.

Namespace: DevExpress.Xpf.Editors.Filtering

Assembly: DevExpress.Xpf.Core.v19.2.dll

Declaration

public class FilterControl :
    Control,
    IDialogContent

The following members return FilterControl objects:

Remarks

Note

The GridControl and TreeListControl use the new filter editor starting from v19.1. To enable the previous filter editor in the GridControl / TreeListControl, set the DataViewBase.UseLegacyFilterEditor property to true.

To enable the new filter editor in the PivotGridControl, set the PivotGridControl.UseLegacyFilterEditor property to false.

 

The FilterControl is a visual control that allows end users to build filter criteria. End users can add an unlimited number of filter conditions and use logical operators to group them:

grid_FilterEditorUI

The FilterControl can control data filtering for the DXGrid control via the DataControlBase.FilteredComponent property, a DataTable component, and any object which implements the DevExpress.Xpf.Editors.Filtering.IFilteredComponent interface. To specify the object to which the FilterControl will supply filter criteria, use the FilterControl.SourceControl property.

Note

Note that although the DXGrid control provides an embedded Filter Editor, you can still use a separate FilterControl, with the DXGrid control to provide standalone filter editing.

After a source control has been assigned to the FilterControl via the FilterControl.SourceControl property, the filter columns and editors used to edit operand values are automatically retrieved from the source control. Filter columns are stored within the FilterControl.FilterColumns collection.

The filter expression built via the FilterControl can be obtained via the FilterControl.FilterCriteria property. This property can also be used to specify filter criteria in code.

To apply a filter created in the FilterControl to the grid control using the FilterControl.ApplyFilter method, use binding for the FilterControl.FilterCriteria property, as shown in the code snippet below.

<dxe:FilterControl x:Name="filterEditor" 
                   SourceControl="{Binding ElementName=filterGrid, Path=FilteredComponent}"
                   FilterCriteria="{Binding ElementName=filterGrid, Path=FilterCriteria, Mode=TwoWay}"/>

Changes made to the source control’s filter criteria are automatically tracked by the FilterControl. Each time the source control’s filtering settings are modified by a user or in code, the FilterControl automatically reflects the changes. Note that filter criteria built via the FilterControl are not automatically applied to the bound source control. To apply the current filter criteria to the source control, use the FilterControl.ApplyFilter method.

The code sample below shows the FilterControl. The Apply Filter button with the ApplyFilterCommand command allows you to apply filter criteria specified in the FilterControl to a bound control.

<dxe:FilterControl x:Name="control" />
<!-- -->
<Button Content="Apply Filter" Command="{Binding ElementName=control, Path=ApplyFilterCommand}"/>

The FilterControl can be used in unbound mode, when it’s not bound to any source control (the FilterControl.SourceControl property is set to null). In this mode, specific columns must be added to the FilterControl.FilterColumns collection manually. An end-user will be able to construct filter criteria using these columns. To get the current filter criteria, use the FilterControl.FilterCriteria property.

Note

A FilterControl is not intended to be used in Windows Forms hosted applications.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FilterControl class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also