-
Thanks to these forums I now know how to extract and display an icon from a given file, and place it in a picture box. However, how can I get that same icon into an ImageList and therefore use it in a ListView (ie. Like a list of files with the correct icon in the listview.)
Any help would be much appreciated.
Thanks in advance.
Stu.
-
Extract the icon and paint to a picture box and make it persistent by assigning the image property to the picture property.
Then use the Add method of the ListImages collection.
Code:
Static iIconCount As Integer
'code to extract and paint an icon
'to the picIcon PictureBox goes here
picIcon.Picture = picIcon.Image
iIconCount = iIconCount + 1
With imlIcons
'the following two properties can
'be set during design time
.MaskColor = picIcon.BackColor
.UseMaskColor = True
.ListImages.Add , "Icon" & iIconCount, picIcon.Picture
End With
The iIconCount in the above example is only there so we can give the icon a unique key in the ListImages collection.
Good luck!
-
Extrating Icons
Great, thanks.
It was the use of Image property I was missing. It now works nicely and my list views have meaningful icons.
Thanks again.