Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by updown
  • *Gurus*
Posted

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).

Posted
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??

Posted

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"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...