title: VB.NET + Add folders to treeview and files to listview
body: <p>I want to create a simple printer manager to use in our Terminal server environment. Because of GPO restrictions, there are limits of what built-in functionality I can use. So I decided to try to write my own simple GUI to do that. </p>
  
  <p>Now, the printers are distributed in a folder, with subfolders to categorize them. In each folder there are .lnk files to the actual printer on the printserver. </p>
  
  <p>What I want to do is to populate a treeview with the folders, and the printers in a listview, based on which item is clicked on the treeview. </p>
  
  <p>I've already managed to search for directories and to search the files for each item I've clicked. But I realized, why not use a collection or similar to do this during the startup of the form? That way, it'll be faster. Because right now, there's a small delay each time I click an item in the treeview. Because it scans for files each time.</p>
  
  <p>How can I add the same to a collection and use that instead?</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>Public Sub populateTreeView(ByVal strPath As String)
  
          Dim di As New IO.DirectoryInfo(strPath)
          Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
          Dim dra As IO.DirectoryInfo
  
          For Each dra In diar1
              ImageList1.Images.Add(GetSmallIcon(dra.FullName))
  
              TreeView1.Nodes.Add("", dra.Name, nIndex)
              nIndex = nIndex + 1
          Next
      End Sub
  
      Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
          ListView1.Clear()
          nIndex = 0
  
          Dim di As New IO.DirectoryInfo(strIniSettings &amp; "\" &amp; TreeView1.SelectedNode.Text)
          Dim diar1 As IO.FileInfo() = di.GetFiles()
          Dim dra As IO.FileInfo
  
          For Each dra In diar1
              Dim strName As String
              strName = Replace(dra.Name, ".lnk", "")
              ImageList2.Images.Add(GetLargeIcon(dra.FullName))
  
              ListView1.Items.Add("", strName, nIndex)
              nIndex = nIndex + 1
          Next
      End Sub
  </code></pre>
  
  <p>Notice the Imagelists? I also get the Icon for each item as well.</p>