Results 1 to 6 of 6

Thread: populating treeview with dir and files..

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    populating treeview with dir and files..

    any method to do this in an extrememly fast way ?

    with no impact on a user waiting for it to fill?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You might need to do that on different thread than the UI Thread .

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    A quick demo . If you have any questions , post here .
    VB Code:
    1. Public Sub FILLTreeV(ByVal path As String)
    2.         Dim FitN As TreeNode
    3.         Dim DitN As TreeNode
    4.  
    5.         For Each file As String In IO.Directory.GetFiles(path)
    6.             FitN = New TreeNode(file)
    7.             Me.TreeView1.Nodes.Add(FitN)
    8.         Next
    9.  
    10.         For Each dir As String In IO.Directory.GetDirectories(path)
    11.             DitN = New TreeNode(dir)
    12.             Me.TreeView1.Nodes.Add(DitN)
    13.             FILLTreeV(dir)
    14.         Next
    15.  
    16.     End Sub
    17.  
    18.  
    19. 'Use
    20.  
    21. FILLTreeV("c:\data")

  4. #4

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    thanks pirate, for the sample... helped...

    and also had a thought - what if i just populated all the directories -

    i reworked your code to populate the tree with the directories only and that is fast ! and looks like the whole file structure is there - just what i want - but

    then if a user clicks on the node to see the insides of the directory then i would populate that on the fly -

    how would i do that? is there an event so i can fill in the files or (subdirectories) under the correct node of the tree?

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    That's easy I think . I'll give you the idea , if you still can't get it to work then let me know (I'm just little busy now) . Ok , use a counter that increments folders found then use this counter as index in the treenode index value . I remember I did it this way and worked well . Sorry as I said I can't give you the full code right now but if you're stuck , then I'll help you .

  6. #6
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Just what I was looking for.


    Things I do when I am bored: DotNetable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width