Click here to Skip to main content
12,401,832 members (49,611 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hello!

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
Comments
lukeer 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 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
 
good
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;

Regards,
Daniele.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100