473,700 Members | 2,845 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 14475
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
2304
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
2855
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
4262
by: GT | last post by:
Could someone please explain how to add images to a ListView other than in the first column?
0
884
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
3745
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 any help. private void listView1_ItemDrag(object sender, ItemDragEventArgs e) { int max =...
0
2004
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 (ListViewItem) color, which I want. Even within the column containing the image, the rest of the column is...
8
5777
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 size as the image size used for the ImageList that stores the images for the ListView.
2
6166
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 - we can use MessageWindow.SendMessage from Microsoft.WindowsCE.Forms or use DllImport and SendMessage....
1
4612
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; this.lstUser.GridLines = true;
0
8709
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8638
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9058
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8952
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5894
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3081
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
2
2371
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2018
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.