如何过滤objectlistview的TreeListView? [英] How to filter objectlistview's TreeListView?

查看:81
本文介绍了如何过滤objectlistview的TreeListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用类似于文档中的委托来过滤 TreeListView :

I tried to filter TreeListView using delegates like in the documentation: Filtering ObjectListView

它是这样的:

this.myTree.ModelFilter = new ModelFilter(delegate(object x) {
    return (((MyTreeNode)x).Type == type); // this code doesn't work, why ?
});

结果是, myTree 应该包括所有具有 .Type 属性等于 type 的节点,在我的情况下,树,为什么???.

As result, myTree should include all nodes with .Type property is equal to type, in my case there are no nodes in the tree, why ???.

但是,如果我将 .Type 属性设置为根节点的类型,那么它将仅是树中的一个根节点,因此在这种情况下它可以工作.

But, if I set .Type property to type of the root node, then it will be only one root node in the tree, so in this case it works.

ETA::为什么无法使用上述代码进行过滤?

ETA: Why filtering with the above code doesn't work ?

推荐答案

从您的问题出发,还不清楚您的 TreeListView 结构是什么样子.但这可能与您想要过滤尚未提取的子项(未扩展的节点)有关.

From your question, it's not entirely clear what your TreeListView structure looks like. But it may have something to do with the fact that you want to filter child items that haven't been fetched yet (unexpanded nodes)?

从您已经引用的教程链接中:

From the tutorial link you already referenced:

过滤和TreeListViews
筛选和TreeListView以可预测但可能是意外的方式交互.
筛选仅考虑当前公开的行(即,其所有祖先均已展开).
在那些行中,如果行或它们的任何后代将被过滤,则行将被过滤过程包括在内.(是的,这是递归的).如果最低级别的子项符合过滤条件,则其所有祖先也将被视为已匹配,因此将显示在控件中.
在大多数情况下,这会提供最可预测和最有用的视觉效果.

Filtering and TreeListViews
Filtering and TreeListViews interact in a predictable but perhaps unexpected fashion.
Filtering considers only rows that are currently exposed (that is, all their ancestorss are expanded).
Within those rows, rows will be included by the filtering process if they or any of their descendents will be included by the filtering. (Yes, this is recursive). If a bottom level child matches the filtering criteria, then all its ancestors will be considered to have matched as well and thus will be shown in the control.
In the majority of situations, this gives the most predictable and useful visual results.

这篇关于如何过滤objectlistview的TreeListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆