ViewFilter.Add(ViewColumnFilterInfo) Method
Adds the specified filter criteria to the collection and thus applies them to a View.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
columnInfo | DevExpress.XtraGrid.Views.Base.ViewColumnFilterInfo | A DevExpress.XtraGrid.Views.Base.ViewColumnFilterInfo object referring to a specific column and the filter condition which will be applied to this column. |
Returns
Type | Description |
---|---|
Int32 | A zero-based integer specifying the position at which the filter condition was added amongst the other filter conditions within the current collection. -1 if the given filter condition’s functionality is disabled (its ColumnFilterInfo.Kind property is set to ColumnFilterType.None or column is null). |
Remarks
The Add method can be used to add specific filter criteria to a View. The DevExpress.XtraGrid.Views.Base.ViewColumnFilterInfo object passed as this method’s paramater identifies a column (GridColumn) and the filter condition (ColumnFilterInfo) which will be associated with this column.
The Add method merely adds the specified ViewColumnFilterInfo object to the ViewFilter collection and returns the position of the new entry.
See the Filter and Search topic for information on constructing filter conditions.
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);