Reputation: 1461
I am trying to add icons next to text in a listview, but I keep getting an error saying I need to imagelist must be initialised before it can be used.
On the form window as it loads, I have the following code:
Private Sub UserForm_Initialize()
ImageList3.ListImages.Add Key:="Koala", Picture:=LoadPicture("\images\add_icon.gif")
end sub
Then I am trying to populate the listview like this
li.ListSubItems.Add , , "Test", "Koala"
What am I doing wrong?
Upvotes: 0
Views: 1724
Reputation: 29466
You need to link your ImageList to the ListView using the Icons
-property. Add the following line in the UserForm_Initialize
- this must be done before you populate the ListView (of course you need to adapt the name of the ListView)
Me.ListView1.Icons = ImageList3
Upvotes: 1