数据绑定到树形列表控制 [英] binding data to the treelist control

查看:122
本文介绍了数据绑定到树形列表控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中包含字段作为IsBulitIn&放一个表;这是位类型。根据字段值过滤我我的表&安培;我有设定数据。我用数据视图为每种类型的数据。现在我有两个数据视图的。我想在运行时创建两个上级节点。这个名字可能是内置集团与& 我的团。 &安培;我想这两个数据视图设置为我的上述两项父节点。

I'm having one table which contains the field as "IsBulitIn" & which is of bit type. Depending on the field value i filtered my table & i got to set of data . I used dataview for each type of data. Now i'm having two dataview's . I want to create two parent nodes at run time . The name may be "BuiltIn Group" & "My Group". & i want to set these two dataviews to the my above two parent node.

是否有可能到数据源属性设置为每个父节点?

Is it possible by to set the datasource property to the each parent node?

感谢。

推荐答案

一般情况下,是有办法做到这一点,但这种方式是不是直线前进。首先,我要告诉,该TreeListNode类不提供DataSource属性。这样,就不可能仅仅设置一个属性,并达到要求的效果。无论如何,我会建议你创建这些节点自己的子节点:

Generally, there is a way to do this, though this way is not a straight forward. First, I should tell, that the TreeListNode class does not provide the DataSource property. So, it is impossible to just set a property and achieve the required effect. Anyway, I would suggest that you create child nodes for these nodes yourself:

void PopulateNodes(TreeListNode parentNode, DataView dataView) { 
            treeList1.BeginUnboundLoad();
            try {
                for(int i = 0; i < dataView.Count; i++) {
                    treeList1.AppendNode(new object[] { dataView[i]["SomeFieldName"] }, parentNode);
                }
            }
            finally {
                treeList1.EndUnboundLoad();
            }
        }

要添加父节点编程,使用下面的代码

To add a parent node programmatically, use the following code:

    TreeListNode parentNode = treeList1.AppendNode(new object[] { "parent" }, null);

这篇关于数据绑定到树形列表控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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