472,374 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 14313
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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.