示例 1
下列代码选择海运国名称 (ShipCountry) 以“F”起始的记录。 使用 ColumnFilterInfo 对象创建所需的筛选。 然后它被指派到 GridColumn.FilterInfo 属性。
C# | 复制代码 |
---|---|
using DevExpress.XtraGrid.Columns; gridView1.Columns["ShipCountry"].FilterInfo = new ColumnFilterInfo("[ShipCountry] LIKE 'F%'"); |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraGrid.Columns GridView1.Columns("ShipCountry").FilterInfo = _ New ColumnFilterInfo("[ShipCountry] LIKE 'F%'") |
示例 2
下列代码展示了如何通过视图的 ColumnView.ActiveFilter 对象,把筛选条件添加到视图。 此筛选条件选择 CategoryName 字段以“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%'", "")); |
Visual Basic | 复制代码 |
---|---|
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%'", "")) |
示例 3
下列代码展示了如何通过视图的 ColumnView.ActiveFilter 对象,把筛选条件添加到视图。 此筛选条件选择在 CategoryName 列中包含“Produce”或“Seafood”取值的记录。
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); |
Visual Basic | 复制代码 |
---|---|
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) |