windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-9ab029f4.md
Represents a collection of filter conditions applied to a View.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[ListBindable(false)]
public class ViewFilter :
CollectionBase,
ICloneable
<ListBindable(False)>
Public Class ViewFilter
Inherits CollectionBase
Implements ICloneable
The following members return ViewFilter objects:
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:
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.
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);
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Columns
'...
Dim view As ColumnView = GridView1
Dim colCategory As GridColumn = view.Columns("CategoryName")
Dim filter As New ColumnFilterInfo("[CategoryName] = 'Produce' OR [CategoryName] = 'Seafood'", "")
view.ActiveFilter.Add(colCategory, filter)
Object CollectionBase ViewFilter
See Also