Home All Groups Group Topic Archive Search About

Recursion with a Tree View and checkboxes

Author
25 Apr 2006 3:35 PM
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

Author
25 Apr 2006 4:28 PM
AMDRIT
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

Show quoteHide quote
"VBNovice05" <tony.schroeder.***@mda.mil> wrote in message
news:1145979309.080565.113520@v46g2000cwv.googlegroups.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
>
Author
25 Apr 2006 10:06 PM
VBNovice05
AMDRIT,

Thanks for the help it worked just like I wanted to.


AMDRIT wrote:
Show quoteHide quote
> 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" <tony.schroeder.***@mda.mil> wrote in message
> news:1145979309.080565.113520@v46g2000cwv.googlegroups.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
> >