如何将列表绑定到TreeView以实现多级别 [英] How to bind list to TreeView to achive multilevel

查看:75
本文介绍了如何将列表绑定到TreeView以实现多级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我想将列表绑定到TreeView。但它应该这样工作:



我使用实体框架。在最简单的情况下,我有2个表与2个协会。



客户

产品



客户与自身连接

Customer.CustomerID - Customer.ParentID



Product.CustomerID - Customer.CustomerID



现在我想填充TreeView并实现以下目标:



客户1 
SubCustomer1
产品1
产品2
产品3
客户2
产品4
客户3
SubCustomer2
产品5
SubCustomer3
SubCustomer4
Product6
Product7
Product8



我只想看到Name属性并以某种方式检测出哪一个被点击。



客户表有3个导航属性

产品

CustomerChildren

CustomerParent



产品表有3个导航在属性,但我不想在TreeView中使用它。



在运行时我想点击一些产品,检测产品是否被选中(如果客户是然后根据其他控件进行一些数据库修改。



有人可以帮忙吗?

解决方案

你应该使用N级数据库驱动的动态菜单概念,它的位置是垂直的

请通过以下链接告诉我是否有任何问题



数据库驱动的动态菜单控制 [ ^ ]



使用EntityFramework [ ^ ]

我想使用一些自动绑定但我创建递归函数用TreeViewItems填充TreeView,然后用另一个TreeViewItems填充TreeViewItem.Items但这个解决方案效率不高。这是一个非常缓慢的解决方案。


Hello

I want to bind list to TreeView. But it should work like that:

I work with entity framework. In easiest case I have 2 tables with 2 associations.

Customer
Product

Customer is connected with itself
Customer.CustomerID - Customer.ParentID
and
Product.CustomerID - Customer.CustomerID

Right now I want to populate TreeView and achieve something like this:

Customer1
    SubCustomer1
        Product1
        Product2
    Product3
Customer2
    Product4
Customer3
    SubCustomer2
        Product5
    SubCustomer3
        SubCustomer4
             Product6
        Product7
    Product8


I want to see only Name properties and somehow detect which one is clicked.

Customer Table has 3 navigation properties
Products
CustomerChildren
CustomerParent

Product table has 3 navigation properties but I don't want to use it in TreeView.

In runtime I want to click on some Product, detect that Product is selected (stop if customer is selected) and then make some database modification according to other controls.

Can someone help?

解决方案

you should use N-level Database Driven Dynamic Menu concept ,and its position vertically
please go through below link and let me know if any issue

Database Driven Dynamic Menu Control[^]

with EntityFramework[^]


I wanted use some automatic binding but I create recursive function to populate TreeView with TreeViewItems and then TreeViewItem.Items with another TreeViewItems but this solution isn't efficient. It is very slow solution.


这篇关于如何将列表绑定到TreeView以实现多级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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