下面的示例展示了如何隐藏在 colLOCATION 列中包含“San Francisco”或“Toronto”的行。 为了筛选数据,创建了 FilterCondition 对象并且把它添加到 TreeList.FilterConditions 集合中。

在默认情况下,筛选被禁用。 把 TreeListOptionsBehavior.EnableFiltering 属性值设置为 true 则启用筛选。

C#CopyCode image复制代码
using DevExpress.XtraTreeList;

treeList1.OptionsBehavior.EnableFiltering = true;
FilterCondition fc = new FilterCondition(FilterConditionEnum.Equals, colLOCATION, "San Francisco");
FilterCondition fc1 = new FilterCondition(FilterConditionEnum.Equals, colLOCATION, "Toronto");
treeList1.FilterConditions.Add(fc);
treeList1.FilterConditions.Add(fc1);
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraTreeList

treeList1.OptionsBehavior.EnableFiltering = True
Dim fc As FilterCondition = New FilterCondition(FilterConditionEnum.Equals, colLOCATION, "San Francisco")
Dim fc1 As FilterCondition = New FilterCondition(FilterConditionEnum.Equals, colLOCATION, "Toronto")
TreeList1.FilterConditions.Add(fc)
TreeList1.FilterConditions.Add(fc1)