Fill treeView from DataTable

P

PawelR

Hello Group,

I have DataTable dt with 3 Columns (id, GroupName, ItemName).
How group in TreeView items by GroupName?

EX:
myTable:
id GroupName ItemName
1 Group1 it1_gr1
2 Group2 it1_gr2
3 Group1 it2_gr1
4 group1 it3_gr1
5 group2 it2_gr2

and treeview
Root
- Group1
- - it1_gr1
- - it2_gr1
- - it3_gr1
- Group2
- - it1_gr2
- - it1_gr2


Thx for yours Help

br.
PawelR
 
N

Nicholas Paldino [.NET/C# MVP]

PawelR,

You will have to do this manually, there is no way to bind to a tree
view in this manner out of the box.

Basically, you will have to cycle through the items, adding the groups
to the tree as you come across new ones. If the group already exists, then
you have to populate the node that represents the group, instead of adding
it to the root.

Hope this helps.
 
P

PawelR

Thanks
for your help.
I do it manually.

PawelR


U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
PawelR,

You will have to do this manually, there is no way to bind to a tree
view in this manner out of the box.

Basically, you will have to cycle through the items, adding the groups
to the tree as you come across new ones. If the group already exists,
then you have to populate the node that represents the group, instead of
adding it to the root.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


PawelR said:
Hello Group,

I have DataTable dt with 3 Columns (id, GroupName, ItemName).
How group in TreeView items by GroupName?

EX:
myTable:
id GroupName ItemName
1 Group1 it1_gr1
2 Group2 it1_gr2
3 Group1 it2_gr1
4 group1 it3_gr1
5 group2 it2_gr2

and treeview
Root
- Group1
- - it1_gr1
- - it2_gr1
- - it3_gr1
- Group2
- - it1_gr2
- - it1_gr2


Thx for yours Help

br.
PawelR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top