I often cheat and do something like:
Me.ListView1.Sm allImageList.Im ages.Add(MyNewI temIcon)
Me.ListView1.It ems.Add(MyItemT ext,
Me.ListView1.Sm allImageList.Im ages.Count - 1)
First it adds the image I want to use to the ListView's small image list.
Then it adds a new item and points the image to the last image in the small
image list, which is the one I just added. I don't recommed this if you're
going to be adding a lot of images because it will end up eating a lot of
memory. It should be fine if you're just doing a runtime population of the
control and won't be adding more afterwards.
"Simon Morris" <nz*********@ho tmail.com> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
How do you add I icon to a ListView at run time, the icon is in a
ImageList (ImageIndex = 0)? I am using the follow code to add item.
Dim item4 As New ListViewItem("L oad Island Data", 1)
item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - sngStartTime,
"0.0" & " sec"))
item4.SubItems. Add("All map data loaded in to memory")
TaslList.Items. AddRange(New ListViewItem() {item4})