Results 1 to 4 of 4

Thread: [RESOLVED] Loading specific files from folder into treeview

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Loading specific files from folder into treeview

    Hi there,

    I have to load more then 8K images into a treeview, which won't work due to out-of-memory-exception, but that's not for now.
    I have a list of all names of the files within the imagefolder. Specific files need to be within a different parent-node.

    How do I accomplish this? (if within an array: how do I apply it within my code?)

    My code (3rd party control):

    Code:
       Dim lnode As New Node("Exceptions")  ' create parentnode
       .Nodes.Add(lnode)  ' add parentnode to treeview
       For Each x In My.Computer.FileSystem.GetFiles(msopath)
          Dim n As New Node(Path.GetFileNameWithoutExtension(x.ToString))
          'n.Image = Image.FromFile(x)  ' <-- comment out for now... out-of-memory exception
          lnode.Nodes.Add(n)  ' add the filnames (and the image) to the parentnode
       Next


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Loading specific files from folder into treeview

    Hi,

    You need to create treenode objects to add it on the treeview control.
    Say, you wanna add 10 filenames to treeview control only in parent nodes

    Code:
     Private Sub AddFilesTreeview()
            If items.Count > 0 Then
                For Each item As String In items
                    Dim treenode As New TreeNode()
                    treenode.Name = item
                    treenode.Text = item
                    TreeView1.Nodes.Add(treenode) ' add the filnames (and the image) to the parentnode
                Next
            End If
        End Sub
    Where items is a List<string> object that contains filenames.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Loading specific files from folder into treeview

    I think your suggestion gave me an idea. Thanks for your input.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Loading specific files from folder into treeview

    Cheers! Welcome!
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

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