2024年终活动

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress XtraGrid网格控件示例七:列过滤

来源:本站原创   发布时间:2012-10-22   浏览:5980次

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
扫码咨询
电话咨询
023-68661681
返回
顶部