Skip to main content

ViewFilter Class

Represents a collection of filter conditions applied to a View.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[ListBindable(false)]
public class ViewFilter :
    CollectionBase,
    ICloneable

The following members return ViewFilter objects:

Remarks

Each ColumnView descendant provides the ColumnView.ActiveFilter property of the ViewFilter type and this represents a collection of filter conditions for the View. Use this collection to apply filter conditions to the View programmatically.

All the conditions within the collection are concatenated by the Boolean AND operator to constitute the overall filter criteria used to filter data. Each filter condition in the collection is represented by a DevExpress.XtraGrid.Views.Base.ViewColumnFilterInfo object which contains two public properties:

  • ViewColumnFilterInfo.Column of the GridColumn type. This defines the column which the associated filter condition is applied to.
  • ViewColumnFilterInfo.Filter of the ColumnFilterInfo type. This specifies the filter condition itself. For more information on constructing filter conditions, see the Advanced Filter and Search Concepts topic.

Filter conditions from the ViewFilter collection will be used to filter data only if the ColumnView.ActiveFilterEnabled property is set to true. This property can be set to false to temporarily disable filtering. This does not remove filter conditions from the collection. To completely remove all the filter conditions the ViewFilter‘s Clear or ColumnView.ClearColumnsFilter method can be called.

To apply filtering to a view, one of the following methods can be used:

For more information refer to the Filter and Search document.

Example

The following code uses the ColumnView.ActiveFilter property to apply a filter. The filter selects records that contain “Produce” or “Seafood” in the CategoryName column.

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Columns;
//...
ColumnView view = gridView1;
GridColumn colCategory = view.Columns["CategoryName"];
ColumnFilterInfo filter = new ColumnFilterInfo("[CategoryName] = 'Produce' OR [CategoryName] = 'Seafood'", "");
view.ActiveFilter.Add(colCategory, filter);

Inheritance

See Also