473,406 Members | 2,387 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,406 software developers and data experts.

Help - Recursively Opening & Closing All Nodes in Treeview

I have built a treeview that looks something like:



Root

.....FolderLevel1a

.........FolderLevel2a

.............Page

.........FolderLevel2b

.............Page

.............Page

.....FolderLevel1b

.........FolderLevel2a

.............Page

.............Page

.........FolderLevel2b

.............Page

(etc.)



I now need to write two functions--one that recursively opens all nodes and open that recursively closes all nodes. I've tried, but I can't seem to make much progress.



Has anyone done this? If so, would you provide some guidance? Or, if anyone else has any suggestions, they would be appreciated too.



Thanks.



Nov 18 '05 #1
1 1944
Your recursive probe is simple to setup. First, your outer loop will iterate the collection of nodes. For each node you will call a function to either close or open the node. Pass a flag into that function to tell the routine whether to close or open. That way, you only need one routine which will either close or open. For each node in your iteration, you will call this function. The function will iteratively call itself as long as their are nodes which have children. On each call it will examine the close flag and determine what to do.

Another approach is just to iterate thru the top level nodes and close them. Lower levels don't need to be closed since they cannot be viewed. Opening would need recursion/.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Lanny McDonald" <lm*******@hotmail.com> wrote in message news:OX**************@TK2MSFTNGP10.phx.gbl...
I have built a treeview that looks something like:



Root

....FolderLevel1a

........FolderLevel2a

............Page

........FolderLevel2b

............Page

............Page

....FolderLevel1b

........FolderLevel2a

............Page

............Page

........FolderLevel2b

............Page

(etc.)



I now need to write two functions--one that recursively opens all nodes and open that recursively closes all nodes. I've tried, but I can't seem to make much progress.



Has anyone done this? If so, would you provide some guidance? Or, if anyone else has any suggestions, they would be appreciated too.



Thanks.



Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: csx | last post by:
Hi all, I'm trying to count the number of leafnodes for a particular node. What im trying to do is make a function, that taking the tree structure: key row desc parent 1 1 A ...
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
3
by: serge calderara | last post by:
Dear all, I have a csv file data which has been read and populate on a dataset object. then I need to bind part of the content of the dataset to a treeview control. I have read that XML format...
4
by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they...
1
by: Lanny McDonald | last post by:
I have built a treeview that looks something like: Root .....FolderLevel1a .........FolderLevel2a
3
by: William Sullivan | last post by:
I desperately want to replace my hand-made ajax treeview with the 2.0 TreeView. The webpage I'm designing uses the postbacks to dynamically fill the treeview. The reason why I'm doing this is...
0
by: Mark Rae | last post by:
Hi, Adding nodes to a TreeView programatically... 1) Instantiate a TreeNode object and set its SelectAction to TreeNodeSelectAction.Expand. 2) Instantiate another TreeNode object and add it...
0
debasisdas
by: debasisdas | last post by:
This sample code displays employee name in the treeview control from the emp table of Scott schema in oracle database. To start with Select Microsoft windows common controls 6.0 (SP6) from...
2
by: David Jackson | last post by:
Hello, I have a TreeView control with "top-level" nodes and "second-level" nodes (probably not the correct terms) as follows: objNode = new TreeNode(); objNode.Text = "2006";...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.