469,898 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

ListView and ImageList/ImageKey

Hi,

I try to use an ImageList with a ListView but that don't work.

I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.

I add a bitmap to the ImageList

When i want to see the item "icon" with the imagelist imageindex
property that work, but with the imagekey property that don't work

At the form load :
ListView1.VirtualListSize = 1

In the RetrieveVirtualItem event (use ImageIndex):
Dim item As New ListViewItem("test", 0)
e.Item = item

That work

In the RetrieveVirtualItem event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("test", str)
e.Item = item

That don't work ! However ImageList1.Images.ContainsKey(str) = true !

Could you help me ?
I have forgotten something ?
Thanks

(excuse me, i don't speak English very well)

Jul 16 '06 #1
4 13975
Hi Archimed

Your problem is with the way you set the image index
<1Dim str As String = "1.JPG"
<2Dim item As New ListViewItem("test", str)
<3e.Item = item

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("test", 0)

The second parameter for the ListViewItem constructor as image index
position of the item's icon within the associated ImageList.

Hope this helps!

Archimed wrote:
Hi,

I try to use an ImageList with a ListView but that don't work.

I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.

I add a bitmap to the ImageList

When i want to see the item "icon" with the imagelist imageindex
property that work, but with the imagekey property that don't work

At the form load :
ListView1.VirtualListSize = 1

In the RetrieveVirtualItem event (use ImageIndex):
Dim item As New ListViewItem("test", 0)
e.Item = item

That work

In the RetrieveVirtualItem event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("test", str)
e.Item = item

That don't work ! However ImageList1.Images.ContainsKey(str) = true !

Could you help me ?
I have forgotten something ?
Thanks

(excuse me, i don't speak English very well)
Jul 17 '06 #2
Hi,
Thanks for your reply

But i need to use the imagelist with ImageKey

The ListViewItem contain however this constructor :
.... New(ByVal text As String, ByVal imageKey As String)

I don't know why that don't work (ImageList1.Images.ContainsKey(str) =
True ! )

gl*********@gmail.com wrote:
Hi Archimed

Your problem is with the way you set the image index
<1Dim str As String = "1.JPG"
<2Dim item As New ListViewItem("test", str)
<3e.Item = item

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("test", 0)

The second parameter for the ListViewItem constructor as image index
position of the item's icon within the associated ImageList.

Hope this helps!

Archimed wrote:
Hi,

I try to use an ImageList with a ListView but that don't work.

I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.

I add a bitmap to the ImageList

When i want to see the item "icon" with the imagelist imageindex
property that work, but with the imagekey property that don't work

At the form load :
ListView1.VirtualListSize = 1

In the RetrieveVirtualItem event (use ImageIndex):
Dim item As New ListViewItem("test", 0)
e.Item = item

That work

In the RetrieveVirtualItem event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("test", str)
e.Item = item

That don't work ! However ImageList1.Images.ContainsKey(str) = true !

Could you help me ?
I have forgotten something ?
Thanks

(excuse me, i don't speak English very well)
Jul 17 '06 #3
Hi

Okay, I didn't see the constructor myself (it's good that they've added
it)...I am able to get it to work when not using the list view in
virtual mode but not while using VirtualMode. Very strange stuff!

Why not try the following as a workaround:

Dim str As String = "1.JPG"
Dim item As New ListViewItem("test",
ListView1.LargeImageList.Images.Key(str))

Of course this means you won't be able to change the View type as
easily (e.g. from LargeIcon to SmallIcon).

Sorry I couldn't help further.

Archimed wrote:
Hi,
Thanks for your reply

But i need to use the imagelist with ImageKey

The ListViewItem contain however this constructor :
... New(ByVal text As String, ByVal imageKey As String)

I don't know why that don't work (ImageList1.Images.ContainsKey(str) =
True ! )

gl*********@gmail.com wrote:
Hi Archimed

Your problem is with the way you set the image index
<1Dim str As String = "1.JPG"
<2Dim item As New ListViewItem("test", str)
<3e.Item = item

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("test", 0)

The second parameter for the ListViewItem constructor as image index
position of the item's icon within the associated ImageList.

Hope this helps!

Archimed wrote:
Hi,
>
I try to use an ImageList with a ListView but that don't work.
>
I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.
>
I add a bitmap to the ImageList
>
When i want to see the item "icon" with the imagelist imageindex
property that work, but with the imagekey property that don't work
>
At the form load :
ListView1.VirtualListSize = 1
>
In the RetrieveVirtualItem event (use ImageIndex):
Dim item As New ListViewItem("test", 0)
e.Item = item
>
That work
>
In the RetrieveVirtualItem event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("test", str)
e.Item = item
>
That don't work ! However ImageList1.Images.ContainsKey(str) = true !
>
Could you help me ?
I have forgotten something ?
Thanks
>
(excuse me, i don't speak English very well)
Jul 17 '06 #4
Thanks a lot ! That's works :)
gl*********@gmail.com wrote:
Hi

Okay, I didn't see the constructor myself (it's good that they've added
it)...I am able to get it to work when not using the list view in
virtual mode but not while using VirtualMode. Very strange stuff!

Why not try the following as a workaround:

Dim str As String = "1.JPG"
Dim item As New ListViewItem("test",
ListView1.LargeImageList.Images.Key(str))

Of course this means you won't be able to change the View type as
easily (e.g. from LargeIcon to SmallIcon).

Sorry I couldn't help further.

Archimed wrote:
Hi,
Thanks for your reply

But i need to use the imagelist with ImageKey

The ListViewItem contain however this constructor :
... New(ByVal text As String, ByVal imageKey As String)

I don't know why that don't work (ImageList1.Images.ContainsKey(str) =
True ! )

gl*********@gmail.com wrote:
Hi Archimed
>
Your problem is with the way you set the image index
<1Dim str As String = "1.JPG"
<2Dim item As New ListViewItem("test", str)
<3e.Item = item
>
You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("test", 0)
>
The second parameter for the ListViewItem constructor as image index
position of the item's icon within the associated ImageList.
>
Hope this helps!
>
Archimed wrote:
Hi,

I try to use an ImageList with a ListView but that don't work.

I make a ListView in VirtualMode with LargeIcon view.
I put the ImageList in the LargeImageList property.

I add a bitmap to the ImageList

When i want to see the item "icon" with the imagelist imageindex
property that work, but with the imagekey property that don't work

At the form load :
ListView1.VirtualListSize = 1

In the RetrieveVirtualItem event (use ImageIndex):
Dim item As New ListViewItem("test", 0)
e.Item = item

That work

In the RetrieveVirtualItem event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("test", str)
e.Item = item

That don't work ! However ImageList1.Images.ContainsKey(str) = true !

Could you help me ?
I have forgotten something ?
Thanks

(excuse me, i don't speak English very well)
Jul 22 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bob C. | last post: by
reply views Thread by sonu | last post: by
8 posts views Thread by Lord Zoltar | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.