473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Fill TreeView with Table data

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
2 1739
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
5
by: lanem | last post by:
I want to display some drill-down data with a datagrid look. I can get the exact functionality I want with a treeview, but I don't like the way the treeview looks and formats the data. I want a...
0
by: Henry | last post by:
I am trying to create a TreeView control that works with an ADO Dataset DataTable or the new BindingSource stuff in .NET 2.0 to build a Treeview that is populated. This is what I came up with...
4
by: Henry | last post by:
Does anybody have a real-world sample of buiding a treeview control using data from database tables? All the sample code I have found either builds the treeview manually or uses a file directory...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
2
by: Adrien Reboisson | last post by:
I'm trying to build a basic DB explorer using C# & Visual Studio 2005. I installed SQL Server 2005 Express, created a blank project, dropped a TreeView, a ListView and a DataGridView : DB objects...
1
by: Luqman | last post by:
I am using Oracle Database Scott.Emp table with Parent/Child relation keys. How can I fill the ASP.Net 2.0 TreeView Control using Sql Data Source. As the TreeView just uses xmldatasource, is it...
3
by: Jeff | last post by:
Hey ..NET 2.0 I'm trying to search a TreeView control for a specific TreeNode The code below doesn't work because it only searches the the top level of the nodes. I would like to program it...
7
by: Joe Cool | last post by:
Let's say I have a Treeview control on a form. Each leaf node in the Treeview has a ContextMenuStrip, each with one ToolStripMenuItem, and all ToolStripMenuItems Click event is handled by a comment...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.