473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 14445
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob C. | last post by:
Hi All, I am using the ImageList/ListView Components to display around 100 images in C#.NET. The issue i have is, some times i may need to display the thumbnail of size more then 256x256 in...
0
by: Andre Viens | last post by:
Hello, I am using the following variation of code from <http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340> to add icons to an imagelist for use in a listview: Private Structure...
2
by: GT | last post by:
Could someone please explain how to add images to a ListView other than in the first column?
0
by: sonu | last post by:
Hi all, Is there any upperbound on capacity of the listview control to hold the images in it. If yes then what could be the solution if i am using that imagelist to display the icons in the...
2
by: jmDesktop | last post by:
I have two listview controls. I have three items of text. I can drag and drop the listview items between each other, back and forth. But the images from the imagelist do not copy over from...
0
by: svx | last post by:
Hello, I am painting individual rows in a ListView control with different colors, depending on state. I am also using a SmallImageList in Detail view. When I set the...
8
by: Lord Zoltar | last post by:
Hi, I've got a list view that displays a series of images. I'd like to be able to draw a divider across the list view to divide the images into groups. Ideally, I'd have a group name, with a line...
2
by: witpo | last post by:
Hi, I would like to display all listview items in one row with scroll bar below it – instead of multiple rows and scroll bar on the right. Someone told me that I can achieve it using...
1
by: elmbrook | last post by:
Hi I am trying to add an image to a listview box. I have the below code and according to me this should work. However, the image does not show at all. I can add an image when I manually add each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.