I'm new to using listview to display icons. I have a few questions remaining...
I am currently using the following code as example. This code works fine, I have questions though
-
For Each File In System.IO.Directory.GetFiles("C:\")
Dim icons As Icon = Icon.ExtractAssociatedIcon(File)
ListView1.Items.Add(File.ToString, ImageList1.Images.Count - 1)
ImageList1.Images.Add(icons)
ListView1.Items.Add(File.ToString, ImageList1.Images.Count)
Next
You may have a look into using treeview... hope that helps
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As Integer
For x = 0 To My.Computer.FileSystem.Drives.Count - 1
If My.Computer.FileSystem.Drives(x).IsReady = True Then
TreeView1.Nodes.Add(My.Computer.FileSystem.Drives(x).Name, My.Computer.FileSystem.Drives(x).Name)
TreeView1.Nodes(My.Computer.FileSystem.Drives(x).Name).Tag = My.Computer.FileSystem.Drives(x).Name
For Each SubDirectory As String In My.Computer.FileSystem.GetDirectories(My.Computer.FileSystem.Drives(x).Name)
TreeView1.Nodes(x).Nodes.Add(SubDirectory, Mid(SubDirectory, 4))
TreeView1.Nodes(x).Nodes(SubDirectory).Tag = SubDirectory
Next
End If
Next
End Sub