Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27206

VS 2012 How to display the subitems of a folder from listview into a treeview

$
0
0
Hi everyone.
As the title states I'm trying to display in a treeview the subitems of a folder from listview.
The listview works somewhat like an explorer and I just pick the folders I want from it and display it's contents on a treeview.
So far I can only show the folders themselves on the treeview with the following code:


Code:

tvInventory.Nodes.Add("Items")
        For i As Integer = 0 To lvExplorer.SelectedItems.Count - 1
            tvInventory.Nodes(0).Nodes.Add(lvExplorer.SelectedItems(i).Name)
        Next

I've added the following code, inside the for cycle, in order to try to add the subitems to selected folders:

Code:

For j As Integer = 1 To lvExplorer.Items(i).SubItems.Count - 1
                tvInventory.Nodes(i).Nodes.Add(lvExplorer.Items(j).Name)
            Next

So the whole code would be something like this:

Code:

tvInventory.Nodes.Add("Items")
        For i As Integer = 0 To lvExplorer.SelectedItems.Count - 1
            tvInventory.Nodes(0).Nodes.Add(lvExplorer.SelectedItems(i).Name)
            For j As Integer = 1 To lvExplorer.Items(i).SubItems.Count - 1
                tvInventory.Nodes(i).Nodes.Add(lvExplorer.Items(j).Name)
            Next
        Next

Although, I only keep getting the folders on the treeview and not the subitems of each folder, something like this:

Name:  File Store.png
Views: 26
Size:  66.5 KB
Attached Images
 

Viewing all articles
Browse latest Browse all 27206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>