Example 1:
下面的代码示例,展示了如何过滤开头字母为F的海运国家。利用ColumnFilterInfo 对象创建所需的过滤器。然后,为其分配GridColumn.FilterInfo属性。
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
下面的示例展示了如何通过ColumnView.ActiveFilter对象添加过滤条件。过滤条件选择过滤以C字母开头的 CategoryName 字段。
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
下面的示例展示了如何通过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);
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)
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/392.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/392.html