Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Im using the code from MSDN[^] to extract icons from file.
I am creating an app launcher with listview, imagelist.
The problem is that only the first icon associated with respective file gets extracted.
So if i have 5 applications with 5 different icon, all 5 gets the icon from the first app.
Since the files in my listview will change over time, i cant specify icons either.
All tips are welcome.
Posted 25-Nov-12 20:53pm
lukeer at 26-Nov-12 3:16am
I bet you've altered the example to fit your needs. Please use the "Improve question" link to add the relevant part of your code (the part that adds items to the listview).
Member 9621169 at 1-Dec-12 5:38am
Thanks! Works like a charm. Tried to figure it out for hours, and such a simple solution it was.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The MSDN sample you referenced add images to the ImageList using the file extension as image key.
Only an image at a time can be associated to a key, thus if you didn't changed this behavior, maybe you have to modify that line of code
imageList1.Images.Add(file.Extension, iconForFile);
should be changed into
imageList1.Images.Add(file.FullName, iconForFile);
or something more convenient.
the same applies to
item.ImageKey = file.Extension;
that should be changed into
item.ImageKey = file.FullName;

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

  Print Answers RSS
Your Filters
0 Sergey Alexandrovich Kryukov 685
1 Manas Bhardwaj 380
2 OriginalGriff 344
3 Abhinav S 293
4 Sampath Lokuge 245
0 Sergey Alexandrovich Kryukov 7,967
1 OriginalGriff 4,332
2 Peter Leow 3,699
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107

Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid