473,386 Members | 1,752 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,386 software developers and data experts.

ListView and Icons

How do you add I icon to a ListView at run time, the icon is in a ImageList
(ImageIndex = 0)? I am using the follow code to add item.

Dim item4 As New ListViewItem("Load Island Data", 1)

item4.SubItems.Add(Format(Microsoft.VisualBasic.Ti mer - sngStartTime, "0.0"
& " sec"))

item4.SubItems.Add("All map data loaded in to memory")

TaslList.Items.AddRange(New ListViewItem() {item4})

Nov 22 '05 #1
2 4103
I often cheat and do something like:

Me.ListView1.SmallImageList.Images.Add(MyNewItemIc on)

Me.ListView1.Items.Add(MyItemText,
Me.ListView1.SmallImageList.Images.Count - 1)

First it adds the image I want to use to the ListView's small image list.
Then it adds a new item and points the image to the last image in the small
image list, which is the one I just added. I don't recommed this if you're
going to be adding a lot of images because it will end up eating a lot of
memory. It should be fine if you're just doing a runtime population of the
control and won't be adding more afterwards.

"Simon Morris" <nz*********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP09.phx.gbl...
How do you add I icon to a ListView at run time, the icon is in a ImageList (ImageIndex = 0)? I am using the follow code to add item.

Dim item4 As New ListViewItem("Load Island Data", 1)

item4.SubItems.Add(Format(Microsoft.VisualBasic.Ti mer - sngStartTime, "0.0" & " sec"))

item4.SubItems.Add("All map data loaded in to memory")

TaslList.Items.AddRange(New ListViewItem() {item4})

Nov 22 '05 #2
I often cheat and do something like:

Me.ListView1.SmallImageList.Images.Add(MyNewItemIc on)

Me.ListView1.Items.Add(MyItemText,
Me.ListView1.SmallImageList.Images.Count - 1)

First it adds the image I want to use to the ListView's small image list.
Then it adds a new item and points the image to the last image in the small
image list, which is the one I just added. I don't recommed this if you're
going to be adding a lot of images because it will end up eating a lot of
memory. It should be fine if you're just doing a runtime population of the
control and won't be adding more afterwards.

"Simon Morris" <nz*********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP09.phx.gbl...
How do you add I icon to a ListView at run time, the icon is in a ImageList (ImageIndex = 0)? I am using the follow code to add item.

Dim item4 As New ListViewItem("Load Island Data", 1)

item4.SubItems.Add(Format(Microsoft.VisualBasic.Ti mer - sngStartTime, "0.0" & " sec"))

item4.SubItems.Add("All map data loaded in to memory")

TaslList.Items.AddRange(New ListViewItem() {item4})

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles A. Lackman | last post by:
Hello, I am having a difficult time trying to get the ListView to Inset an new item at a particular index (Using Small or Large Icons). The following is an example: Private Sub...
0
by: Goldsworth_Systems | last post by:
On a VB6 form, I have a listview control associated with an imagelist control. The icons from the imagelist control (ImageList1) to display in the listview control (ListView1) are set by the...
3
by: Ian | last post by:
Hi, I've been trying to create a listview and treeview with icons. You would think it's a pretty straight forward task. API documentation states you simply assign an ImageList - that's been...
3
by: scoobydoo | last post by:
hi, I have a problem displaying icons at the right colour depthin a ListView. I've made an icon file, (using IconWorkshop 5), it has 3 icons within it. A 32x32 32bpp XP style icon, a 32x32...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
1
by: Víctor | last post by:
I'm doing a kind of file explorer with some additional funcionalities. The problem is that I'm not able to draw file extension icons in a ListView. I know how obtain icons, but when I try to draw...
3
by: Steve | last post by:
I have windows form with ListView control. The ListView control has few columns which user can sort by clicking the column header. I want the column header have the small triangle indicator of...
1
by: Sander R | last post by:
Hi, I can't get the the listview (or toolbar) to display the alpha channels of XP icons correctly. I have a manifest file for my binary, and the xp theme is applied correctly. It is only the...
4
by: Ira Siyal | last post by:
Hi I had a project in VB6 which I upgraded to VB.NET recently. In the app, I am facing some issue with listview control. In the earlier app, I have set the Icons in listview through an...
0
by: twoSeven | last post by:
hi, Here is what i want to do. I am making a file and folder browser similar to Windows Explorer with a treeview and listview.. In that, i get icons and thumbnails of a particular file/folder from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
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...

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.