我有2列x和Y.我需要根据2列的值过滤网格。 例如:假设我的过滤条件为真,那么它应检查两列的值,如果任何列值为true,则不应过滤该行。如果该值都不为真,则应该过滤该行。
答案 0 :(得分:9)
我可以想到一个快速解决方案。下面的代码将在2列上设置普通过滤器,然后您只需更改列LogicalOperator。
private void Filter() {
Infragistics.Win.UltraWinGrid.FilterCondition fc = new Infragistics.Win.UltraWinGrid.FilterCondition();
fc.CompareValue = "someValue1";
fc.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["col_x"].FilterConditions.Add(fc);
Infragistics.Win.UltraWinGrid.FilterCondition fc2 = new Infragistics.Win.UltraWinGrid.FilterCondition();
fc2.CompareValue = "someValue2";
fc2.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["col_y"].FilterConditions.Add(fc2);
// set the logical operator of the columns on the band
ultraGrid1.DisplayLayout.Bands[0].ColumnFilters.LogicalOperator = Infragistics.Win.UltraWinGrid.FilterLogicalOperator.Or;
}
这是你在找什么?