473,776 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("L oad Island Data", 1)

item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - 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 4119
I often cheat and do something like:

Me.ListView1.Sm allImageList.Im ages.Add(MyNewI temIcon)

Me.ListView1.It ems.Add(MyItemT ext,
Me.ListView1.Sm allImageList.Im ages.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*********@ho tmail.com> wrote in message
news:ut******** ******@TK2MSFTN GP09.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("L oad Island Data", 1)

item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - 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.Sm allImageList.Im ages.Add(MyNewI temIcon)

Me.ListView1.It ems.Add(MyItemT ext,
Me.ListView1.Sm allImageList.Im ages.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*********@ho tmail.com> wrote in message
news:ut******** ******@TK2MSFTN GP09.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("L oad Island Data", 1)

item4.SubItems. Add(Format(Micr osoft.VisualBas ic.Timer - 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
254
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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ListView2.Items.Add(New ListViewItem("1", 0)) ListView2.Items.Add(New ListViewItem("3", 0)) ListView2.Items.Add(New ListViewItem("4", 0)) ListView2.Items.Insert(1,...
0
1515
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 following line: ListView1.Icons = ImageList1 This seems to work OK. After conversion to VB.Net, I get the following warning: UPGRADE_WARNING: Couldn't resolve default property of object ListView1.Icons. Click for more:...
3
12168
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 populated either using VS.NET (my method) or programatically. I assigned the imagelist to the small icons in the listview. Even VS.NET has been satisfied with what I'm doing as it shows the listitems/treenodes with icons. As soon as I build/run...
3
6580
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 32bpp non-xp icon (no transparency), and a 16x16 version. I add these icons to an ImageList, which is then assigned to the LargeImageList property of the ListView.
3
9317
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, checkbox's and icons are displayed as they are meant to be. My problem is this, I am trying to achieve the same results as I get with CheckListBox(s), where I am able to select (Check-mark) various checkboxs items and able to alter the data. I do...
1
15103
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 file icon, this isn't showed. I tried to do by two ways: 1- By creating the ListViewItem and adding it to ListView, then I get rectangle of icon element and paint a new icon in rectangle coordenates. I'm able to view icons while they are...
3
5894
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 sort order. How can I implement that? Thanks
1
1454
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 icons in the listview and toolbar (which uses standard imagelists that does not work). Anybody know how to fix this? Really appriciate any help :-)
4
2238
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 imagelist. but i notice that while i execute the project in .net, the step that sets the icon prop. throws an exception.
0
1553
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 a function(getMyIcon()) which interacts with shell to get icons and updates the two imagelists( for small and large icons).this in turn is used to update a listview to show the file/folder name and the icons. The problem is the UI becomes...
0
9628
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
9464
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
9923
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6722
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();...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.