473,327 Members | 1,892 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,327 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 1940
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.