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

ViewFilter Class

Represents a collection of filter conditions applied to a View.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v18.2.dll

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 shows how to add a filter condition to a View via its ColumnView.ActiveFilter object. The filter condition selects records which contain the values “Produce” or “Seafood” in the CategoryName column.

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

Inheritance

See Also