updown Posted September 19, 2002 Posted September 19, 2002 (edited) Hi! I'm creating an app witch has a TreeView control named TVC. At some point I will need to save my app data to a file. My problem is I can't go through all TVC nodes to store them in a file. I can only access the first set of childnodes in the control. To get over this I started to think of another way of doing this and I came up with this: Dim a, b For a = 1 To TVC.Nodes.Count MsgBox(TVC.Nodes.Item(a - 1).Text) If TVC.Nodes.Item(a - 1).Nodes.Count > 0 Then For b = 1 To TVC.Nodes.Item(a - 1).Nodes.Count MsgBox(TVC.Nodes.Item(a - 1).Nodes.Item(b - 1).Text) Next End If Next The code above allow me to store information from the first and second nodes but I will have to limit my controll to a number of sub child nodes. Can anyone give me a help on this... Thanks (I'm using VB.NET for a week. I was used to work with VB6) Edited September 19, 2002 by updown Quote
*Gurus* Thinker Posted September 19, 2002 *Gurus* Posted September 19, 2002 Can't take the time to write code for you, but you might need a recursive function that you can pass a node to, and it will process all the child nodes, calling itself for each child node. This will work down to whatever level you have (or until you run out of memory). Quote Posting Guidelines
updown Posted September 19, 2002 Author Posted September 19, 2002 This will work down to whatever level you have (or until you run out of memory). I did'n knew that a funcion could call itself. I'm coding it but do you think that it is possible to run out of memory with about nine or ten levels of childs?? Quote
*Gurus* Thinker Posted September 19, 2002 *Gurus* Posted September 19, 2002 I wouldn't think 9 or 10 levels would be too much myself. But I haven't done anything recursive in .net that has gone more than 3 levels deep. Quote Posting Guidelines
updown Posted September 19, 2002 Author Posted September 19, 2002 Recursion I've finished the code but I haven't tried it with more than 4 levels. Tomorrow I will try with more levels and then I will say something. Quote
updown Posted September 20, 2002 Author Posted September 20, 2002 The recursive function works great Ok I've finished the code and tried it for 20 sub levels and it worked with no problem. I don't have the code in this computer so in a day or two I'll put it here. It might help some other users. Thanks Thinker for your idea. "The fear of being free makes the pryde of being slave" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.