grid应用过滤器
grid要应用过滤器,使用DataControlBase.FilterCriteria或DataControlBase.FilterString原型。这两个属性指定grid的过滤器,即可以由应用到多个列多个条件。当使用DataControlBase.FilterCriteria属性,您应该创建一个CriteriaOperator对象或其派生物,代表过滤器表达式:
C#
grid.FilterCriteria = (
new BinaryOperator("OrderDate", new DateTime(1995, 1, 1), BinaryOperatorType.Less) &
new BinaryOperator("UnitPrice", 10, BinaryOperatorType.Less)) |
( new BinaryOperator("OrderDate", new DateTime(1996, 1, 1), BinaryOperatorType.GreaterOrEqual) &
new BinaryOperator("UnitPrice", 100, BinaryOperatorType.GreaterOrEqual));
或者您可以使用CriteriaOperator.Parse方法:
C#
grid.FilterCriteria =
CriteriaOperator.Parse("( < #1/1/1995# AND < 10)" +
" OR ( >= #1/1/1996# AND >= 100)");
该DataControlBase.FilterString属性允许你指定过滤字符串:
C#
grid.FilterString = "( < #1/1/1995# AND < 10)" +
" OR ( >= #1/1/1996# AND >= 100)";
谢谢分享啊,学习了
页:
[1]