Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListView with images don't display

Status
Not open for further replies.

CoolWeb

Programmer
Jun 2, 2005
4
0
0
BE
I have created a listview and I putted image on each listViewItem.

I see that there is the place for the image on each row when the program run (blank space) but I don't see the image. Why? Is there a problem with the format of the image (Bmp)?

My code: (lst_Report is the listView and images come from an imageList).

Me.lst_Report.Items.Clear()

liste = Me.refreshListe

For Each r In liste.Rows
item = New ListViewItem(CType(r.Item ("FILENUMBER"), String) & "/" & CType(r.Item("SEQUENTIEL"), Integer).ToString("000"))
item.SubItems.Add(CType(r.Item("PRONOUNCEMENTDATE"), Date).ToString("dd\/MM\/yyy"))

If (r.IsNull("DATE_GEN") = False) Then
item.SubItems.Add(CType(r.Item("DATE_GEN"), Date).ToString("dd\/MM\/yyy"))
Else
item.SubItems.Add("")
End If

Me.lst_Report.Items.Add(item)

If (r.IsNull("DATE_GEN") = True) Then
item.ImageIndex = 1
Else
item.ImageIndex = 0
End If
Next

Me.lst_Report.Update()
 
What view are you using?? (the property)

the listview also has a smallimagelist and a largeiamge list play around with those.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
I tried with the 3 image lists possible and I see nothing, but into the designer of VS I have added an item and I see the ICO!!

But not in runtime, I don't understand.
 
Check that you are assigning the Imagelist to the Listview at design time, or secondly, that you're not removing it at runtime. There are 2 imagelist properties of the Listview, namely SmallImageList and LargeImageList.

If that isnt the case, just alter your code slightly, to move the Me.lst_Report.Items.Add(item) line, to just above the Next statement


Sweep
...if it works dont mess with it
 
Yes tere are 2 properties.
I changed the place of the line Me.lst_Report.Items.Add(item).

Nothing is displayed.

Jordens Christophe
Belgium
 
I dont get it. What kind of view are you specifying for your list view?

The code below works fine for me
Code:
xlist.View = View.List
xlist.SmallImageList = Me.ximage
xlist.LargeImageList = Me.ximage

Dim l As ListViewItem

l = New ListViewItem("Text1", 0)
xlist.Items.Add(l)

l = New ListViewItem("Text2", 1)
xlist.Items.Add(l)




Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top