By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,995 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,995 IT Pros & Developers. It's quick & easy.

Fill treeView from DataTable

P: n/a
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
Aug 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com
"PawelR" <p@p.pwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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


Aug 7 '06 #2

P: n/a
Thanks
for your help.
I do it manually.

PawelR
Użytkownik "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.comnapisał w wiadomo¶ci
news:ed**************@TK2MSFTNGP02.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com
"PawelR" <p@p.pwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>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



Aug 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.