Recursion with a Tree View and checkboxes

  • Thread starter Thread starter VBNovice05
  • Start date Start date
V

VBNovice05

I am creating a project that will populate a Tree View with information
from a Cd, Zip, or Floppy. I have the user selected the files they
want to copy.

Exampe: A:\ (Directory) X

- ABC1234 (Folder) X
- Test.html (File) X
- ZXY4567 (Folder)
- WTY5678 (Folder) X
- Test2.html (File) X
- Budget.xls (File)

X = items that the user selects

I want to be able to go through all the Tree Nodes and get the files
that have been selected. If the folder above the item is not selected I
still want the code to go into that folder to see if an item is
selected.

If someone could point me in the right direction I would greatly
appricate it.

VBNovice
 
Take a look at this, I just posted it to help someone else. I only needed
to modify the search criteria to send to you.

'//Initial usage
'//Dim oChecked as Arraylist = Walktree(me.treeview1.nodes)

Private Function WalkTree(ByVal PNodes As TreeNodeCollection) As ArrayList

Dim oRet As ArrayList, iCount As Integer
Dim iTemp As ArrayList

oRet = New ArrayList
iCount = -1

For Each node As TreeNode In PNodes
If node.Checked Then
oRet.Add(node)
End If

iTemp = WalkTree(node.Nodes)
oRet.AddRange(iTemp.ToArray)

Next

Return oRet

End Function
 
Back
Top