Hello everyone,
I am making an application that has a treeview control that should show the drives and their folders of the user's system. To make this a good overview, it would be nice if the icons that go with the folder or drive are shown in the treeview.
Drawing.Icon.ExtractAssociatedIcon works great for files, but tells me 'File not found' when I try to extract the icon of a folder.
This is the code I have now to add the C-drive's treeviewnode:
Is there a way in VB.NET to extract icons from folders and drives?VB Code:
Dim nodeNew As New TreeNode nodeNew.Text = "C:\" nodeNew.Tag = "C:\" Dim MyIcon As Drawing.Bitmap = Drawing.Icon.ExtractAssociatedIcon("C:\").ToBitmap() 'The line above gives me a file-not-found error. Dim imlIcons As New ImageList imlIcons.Images.Add(MyIcon) nodeNew.ImageIndex = imlIcons.Images.Count - 1 tvwFolder.ImageList = imlIcons tvwFolder.Nodes.Add(nodeNew)
Thanks for your help,
Alexander.
P.S. On a side note, is there a way to set the image for a treeview node without the use of an imagelist?




Reply With Quote