Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I know there are 1000+ examples of doing this, but I cannot seem to make it work.

What I have tried:

This is my sample. The first part is just a bit of code proving that there is an image in the first position. This is a sample of what I have tried.

C#
imageList1.Images.Add("pic1", Image.FromFile("c:\\egg\\test\\014.jpg"));
            pictureBox1.Image = imageList1.Images[0];

            listView1.View = View.LargeIcon;
            imageList1.ImageSize = new Size(32, 32);
            listView1.LargeImageList = imageList1;
            ListViewItem item = new ListViewItem();
            item.ImageIndex = 0;
            listView1.Items.Add(item);
Posted
Updated 15-Sep-23 3:07am
v2

Google Search is your best friend. There are thousands of examples on how to do this: winform listview using imagelist examples C# - Google Search[^]

YouTube is your other best friend: winform listview using imagelist - YouTube Search[^]

Pick an example that best meets your needs.
 
Share this answer
 
Comments
David Edwards 2022 15-Sep-23 10:07am    
I did search and tried to apply what I saw. Plus, read your rules, "4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question."
Graeme_Grant 15-Sep-23 17:08pm    
Above is not RTFM, it's providing options. We do this all the time.
Set the ImageSize BEFORE you add the items: otherwise, it discards all images that aren't exactly right.
C#
imageList1.ImageSize = new Size(32, 32);
ImageList1.Images.Add("pic1", Image.FromFile("c:\\egg\\test\\014.jpg"));

pictureBox1.Image = imageList1.Images[0];

listView1.View = View.LargeIcon;
listView1.LargeImageList = imageList1;
ListViewItem item = new ListViewItem();
item.ImageIndex = 0;
listView1.Items.Add(item);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900