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 with Table data

P: n/a
RP
I have an Access Table with following columns:

GID (auto number)
PID number
TreeID Text
ItemName Text

This table consists of records in the following manner:

GID PID TreeID ItemName
----- ------ --------- ------------
1 1 001 RootNode
2 2 001001 Books
3 3 001002 CDs
4 4 001003 Phones
5 2 001001001 Fiction
6 2 001001002 Non-Fiction
7 3 001002001 Pop
8 3 001002002 Classic

Here PID is the ParentID and TreeID is the tag that we want to give to
the node.

Here, the root node TreeID is 001. That is the tag of the root node.
It contains nodes, namely: Books, CDs, Phones with incremental TreeIDs
and prefixed with 001 since they belong to root 001.
Now the Books Node (001001) has child nodes Fiction (001001001) and
Non-Fiction (001001002).
Similarly, CDs Node (001002) has child nodes Pop (001002001) and
Classic (001002002).

I want to fill the TreeView control accordingly at run-time.
I am able to make the root and the main nodes within it. But I am not
able to code how the n number of childs will get accomodated.
Dec 14 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
This looks very familiar.

Regardless, it's simple to do.

Cycle through your rows, and for each row, parse out the TreeID. Read
the first three characters, and look for that id in the Nodes collection off
the TreeView instance. If it returns a node, then look for the next three
characters, and so on, and so on. If you don't find the node, then add it.
Then move to the next line.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"RP" <rp*********@gmail.comwrote in message
news:5a**********************************@i12g2000 prf.googlegroups.com...
>I have an Access Table with following columns:

GID (auto number)
PID number
TreeID Text
ItemName Text

This table consists of records in the following manner:

GID PID TreeID ItemName
----- ------ --------- ------------
1 1 001 RootNode
2 2 001001 Books
3 3 001002 CDs
4 4 001003 Phones
5 2 001001001 Fiction
6 2 001001002 Non-Fiction
7 3 001002001 Pop
8 3 001002002 Classic

Here PID is the ParentID and TreeID is the tag that we want to give to
the node.

Here, the root node TreeID is 001. That is the tag of the root node.
It contains nodes, namely: Books, CDs, Phones with incremental TreeIDs
and prefixed with 001 since they belong to root 001.
Now the Books Node (001001) has child nodes Fiction (001001001) and
Non-Fiction (001001002).
Similarly, CDs Node (001002) has child nodes Pop (001002001) and
Classic (001002002).

I want to fill the TreeView control accordingly at run-time.
I am able to make the root and the main nodes within it. But I am not
able to code how the n number of childs will get accomodated.

Dec 14 '07 #2

P: n/a
RP
Nicholas, it would be good if you can illustrate by code. However,
I'll just try what u suggested.

On Dec 14, 8:40 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
This looks very familiar.

Regardless, it's simple to do.

Cycle through your rows, and for each row, parse out the TreeID. Read
the first three characters, and look for that id in the Nodes collection off
the TreeView instance. If it returns a node, then look for the next three
characters, and so on, and so on. If you don't find the node, then add it.
Then move to the next line.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
Dec 15 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.