Treeview C#与没有parentid的数据库绑定。 [英] Treeview C# binding with database with no parentid.
问题描述
我有类似这样的表格。我创建了一个示例数据库,需要与Treeview绑定。问题是它没有ParentId。而不是在一个步骤过程中它被制作。
I have a similar table like this. I created a sample Database, which needs to be binded with Treeview. The problem is it doesnot have ParentId. Instead in a step process it is made.
dId step1 step2 step3 step4 step5 dname
1 0 0 0 0 0 drinks
2 1 0 0 0 0 cold
3 1 1 0 0 0 pepsi
4 1 1 1 0 0 zero
5 1 1 2 0 0 light
6 1 1 3 0 0 heavy
7 1 2 0 0 0 cola
8 1 2 1 0 0 zero
9 1 2 2 0 0 light
10 1 2 2 1 0 onelight
11 1 2 2 2 0 twolight
12 1 3 0 0 0 7Up
13 2 0 0 0 0 hot
14 2 1 0 0 0 coffee
15 2 1 1 0 0 black
16 2 1 2 0 0 Espresso
17 2 1 3 0 0 Latte
18 2 1 4 0 0 Cappucino
19 2 2 0 0 0 Tea
20 2 2 1 0 0 Ginger
21 2 2 2 0 0 Lemom
22 2 2 3 0 0 Mint
23 2 2 3 1 0 Peppermint
24 2 2 3 2 0 Normalmint
25 3 0 0 0 0 hotcold
26 3 1 0 0 0 water
27 3 2 0 0 0 lassi
28 3 2 1 0 0 Mango
29 3 2 2 0 0 plain
i想要这样的树视图: -
https://photos.google.com/share/AF1QipMwvbOB7R4oRVBRUGeNZ7aOt2j4ZfiRU2DS_SZbiOZQaCaOyAs_A54bzYxzpFmrLA?key = WFBsR1FGN1lEa1lhMzBRZEZrdFNQLVRCeGI4ei1n
我尝试过:
我是WPF的新手,treeview是如此新的概念。我无法从哪里开始。我学习了分层数据模板。但我不知道如何使用这个数据库。我找不到类似这样的合适解决方案。所以只有我在这里发布问题。
i want a treeview like this :-
https://photos.google.com/share/AF1QipMwvbOB7R4oRVBRUGeNZ7aOt2j4ZfiRU2DS_SZbiOZQaCaOyAs_A54bzYxzpFmrLA?key=WFBsR1FGN1lEa1lhMzBRZEZrdFNQLVRCeGI4ei1n
What I have tried:
I am new to WPF and treeview is so new concept. I couldn't where to start. I learned about Hierarchical data template. But I don't know how to work with this database. I couldn't find a proper solution similar like this. So only I am posting the question here.
推荐答案
你有一个父母:它是饮料
然后你有冷(饮料)。
在冷下,你有百事可乐,然后是百事可乐。
等
画一张照片。
< a href =https://www.c-sharpcorner.com/UploadFile/SamTomato/simple-wpf-treeview-control-programmatically/>以编程方式简单的WPF TreeView控件 [ ^ ]
You have a "parent": it's "drinks"
Then you have "cold" (drinks).
Under "cold", you have "Pepsi" and then types of Pepsi.
etc.
Draw a picture.
Simple WPF TreeView Control Programmatically[^]
这篇关于Treeview C#与没有parentid的数据库绑定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!