TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Notices

Reply
 
Thread Tools Display Modes
Old 14-12-2007, 10:31 PM   #1
RP
Guest
 
Posts: n/a
Fill TreeView with Table data

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.
  Reply With Quote
Old 14-12-2007, 10:35 PM   #2
Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
Re: Fill TreeView with Table data

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]
- mvp@spam.guard.caspershouse.com

"RP" <rpk.general@gmail.com> wrote in message
news:5aef3c9c-3efd-48f7-876f-8dc1e9f7aa87@i12g2000prf.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.



  Reply With Quote
Old 15-12-2007, 09:59 AM   #3
RP
Guest
 
Posts: n/a
Re: Fill TreeView with Table data

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.com> wrote:
> 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


  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 05:56 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional