471,066 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Recursion with a Tree View and checkboxes

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

Apr 25 '06 #1
2 1480
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

"VBNovice05" <to****************@mda.mil> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
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

Apr 25 '06 #2
AMDRIT,

Thanks for the help it worked just like I wanted to.
AMDRIT wrote:
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

"VBNovice05" <to****************@mda.mil> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
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


Apr 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by csx | last post: by
43 posts views Thread by Lorenzo Villari | last post: by
18 posts views Thread by MTD | last post: by
35 posts views Thread by Muzammil | last post: by
reply views Thread by leo001 | last post: by

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.