Click here to Skip to main content
12,954,203 members (75,156 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 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
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
Top Experts
Last 24hrsThis month
OriginalGriff 6,524
CHill60 3,490
Maciej Los 3,123
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2017
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