473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 813
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
2837
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
2255
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
2158
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
1285
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
1951
by: Lanny McDonald | last post by:
I have built a treeview that looks something like: Root .....FolderLevel1a .........FolderLevel2a
3
1619
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
2492
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
16266
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
1608
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";...
10
34419
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in...
0
7224
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
7118
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
7323
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,...
1
7038
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
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5625
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,...
1
5049
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.