Example 1
The following code selects records whose shipping country names start with 'F'. The required filter is created using a ColumnFilterInfo object. It's then assigned to the GridColumn.FilterInfo property.
C#
using DevExpress.XtraGrid.Columns;
gridView1.Columns["ShipCountry"].FilterInfo =
new ColumnFilterInfo("[ShipCountry] LIKE 'F%'");
VB
Imports DevExpress.XtraGrid.Columns
GridView1.Columns("ShipCountry").FilterInfo = _
New ColumnFilterInfo("[ShipCountry] LIKE 'F%'")
Example 2
The following code shows how to add a filter condition to a View via its ColumnView.ActiveFilter object. The filter condition selects records whose CategoryName fields start with 'c'.
C#
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Columns;
//...
ColumnView view = gridView1;
view.ActiveFilter.Add(view.Columns["CategoryName"],
new ColumnFilterInfo("[CategoryName] Like 'c%'", ""));
VB
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Columns
'...
Dim view As ColumnView = GridView1
view.ActiveFilter.Add(view.Columns("CategoryName"),
New ColumnFilterInfo("[CategoryName] Like 'c%'", ""))
Example 3
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.
C#
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);
VB
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Columns
'...
Dim view As ColumnView = GridView1
Dim viewFilterInfo As New ViewColumnFilterInfo(view.Columns("CategoryName"), _
New ColumnFilterInfo("[CategoryName] = 'Produce' OR [CategoryName] = 'Seafood'", ""))
view.ActiveFilter.Add(viewFilterInfo)
No comments:
Post a Comment