473,554 Members | 3,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Virtu alListSize = 1

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

That work

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

That don't work ! However ImageList1.Imag es.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 14463
Hi Archimed

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

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("t est", 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.Virtu alListSize = 1

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

That work

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

That don't work ! However ImageList1.Imag es.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.Ima ges.ContainsKey (str) =
True ! )

gl*********@gma il.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("t est", str)
<3e.Item = item

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("t est", 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.Virtu alListSize = 1

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

That work

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

That don't work ! However ImageList1.Imag es.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("t est",
ListView1.Large ImageList.Image s.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.Ima ges.ContainsKey (str) =
True ! )

gl*********@gma il.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("t est", str)
<3e.Item = item

You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("t est", 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.Virtu alListSize = 1
>
In the RetrieveVirtual Item event (use ImageIndex):
Dim item As New ListViewItem("t est", 0)
e.Item = item
>
That work
>
In the RetrieveVirtual Item event (unse ImageKey) :
Dim str As String = "1.JPG"
Dim item As New ListViewItem("t est", str)
e.Item = item
>
That don't work ! However ImageList1.Imag es.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*********@gma il.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("t est",
ListView1.Large ImageList.Image s.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.Ima ges.ContainsKey (str) =
True ! )

gl*********@gma il.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("t est", str)
<3e.Item = item
>
You can remove line <1and change line <2to this:
<2Dim item as new ListViewItem("t est", 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.Virtu alListSize = 1

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

That work

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

That don't work ! However ImageList1.Imag es.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
2299
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 ImageList. But the ImageList Component supports only size upto 256x256. What is the best way to handle this?
0
2829
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 SHFILEINFO Public hIcon As IntPtr ' : icon Public iIcon As Integer ' : icondex Public dwAttributes As Integer ' : SFGAO_ flags
2
4257
by: GT | last post by:
Could someone please explain how to add images to a ListView other than in the first column?
0
882
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 listview. Currently I am able to add 8110 items in the listview after this it is giving me exception that image could not be added to imaglist.
2
3742
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 listview1 to listview2, only the text does. Both listviews have their smallimagelist as the single imagelist I have. Here is my code and thank you for...
0
1988
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 SmallImageList.TransparentColor to the correct color, the background color of the image becomes the BackColor of the ListView control itself, instead of the row...
8
5762
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 underneath it that spans the ListView. How could this be done? I tried using an image as the divider, but it forced the divider image to be the same...
2
6127
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 LVM_SETITEMPOSITION message. According to my knowledge code below should set position for each item added to listView control. There are two ways of doing it -...
1
4595
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 item but not when I add the items as an array. Can someone please tell me what is going wrong? this.lstUser.View = View.Details; ...
0
7596
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7887
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5152
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3545
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2015
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
838
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.