473,378 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How To Get Icons For Pictures Files in vb.net

I Tried To Get Icons Of files system and display it in my list Box
But i got an empty icon For Picture Files

This Is My Code:

Expand|Select|Wrap|Line Numbers
  1.     Public Sub ExtractAssociatedIconEx()
  2.         ' Initialize the ListView, ImageList and Form.
  3.         listView1 = New ListView()
  4.         imageList1 = New ImageList()
  5.         listView1.Location = New Point(37, 12)
  6.         listView1.Size = New Size(161, 242)
  7.         listView1.SmallImageList = imageList1
  8.         listView1.View = View.SmallIcon
  9.         Me.ClientSize = New System.Drawing.Size(292, 266)
  10.         Me.Controls.Add(Me.listView1)
  11.         Me.Text = "Form1"
  12.  
  13.         ' Get the c:\ directory. 
  14.         Dim dir As New System.IO.DirectoryInfo(TextBox1.Text)
  15.  
  16.         Dim item As ListViewItem
  17.         listView1.BeginUpdate()
  18.         Dim file As System.IO.FileInfo
  19.         For Each file In dir.GetFiles()
  20.  
  21.             ' Set a default icon for the file. 
  22.             Dim iconForFile As Icon = SystemIcons.WinLogo
  23.  
  24.             item = New ListViewItem(file.Name, 1)
  25.  
  26.             ' Check to see if the image collection contains an image 
  27.             ' for this extension, using the extension as a key. 
  28.             If Not (imageList1.Images.ContainsKey(file.Extension)) Then
  29.  
  30.                 ' If not, add the image to the image list.
  31.                 iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName)
  32.                 imageList1.Images.Add(file.Extension, iconForFile)
  33.             End If
  34.             item.ImageKey = file.Extension
  35.             listView1.Items.Add(item)
  36.  
  37.         Next file
  38.         listView1.EndUpdate()
  39.     End Sub
How I Can Get Icons For picture Files ?

Thanks
Aug 30 '14 #1
0 1196

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sto | last post by:
look at this picture http://upload.cs99.net/e.gif i use the function SHGetFileInfo to get file icons. but these icons are not very nice. there are some black things round of the icons. many...
1
by: O.A.Haugum | last post by:
Hi I want to use a lot of icons in panels in a status bar. The icons shall show the current status of operations and has to be changed programmatically. Is it possible to store the icons...
21
by: MLH | last post by:
If I choose a command button on a form in design view, open the properties box and click the Picture property and its wiz button, I'm presented with a lengthy list of pictures. Everything from Add...
1
by: andreas | last post by:
Hi, with imagelist it is possible to hide pictures files in a program is there a possibility to hide sound files (like wav) in a vb.net program? thanks for any response
9
by: mimenko | last post by:
Hello, I'd want to show and hide the same icons (pictures) on a web page that contains several icons. Some are identical, some are different (for ex : 3 items "A", 4 items "B", 2 items "C"). Is...
1
by: Tom | last post by:
This may seem a little strange, but in all my years of developing Windows Forms apps, I've never really used Resource files; however, I would like to start doing so in order to store icons,...
4
by: O | last post by:
My files I have on my desktop have disappeared from the desktop. The strange thing is that when I go on my computer they appear to be under desktop, and i Can access from there. but there not in...
7
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of...
3
by: cal | last post by:
Hi group, Wich one is the class to handle desktop icons? I want to modify for example the file path the Icon points to. of course, its the path of the file u open when u doubleclick the icon. ...
5
by: Alexnb | last post by:
Hello I am sure most of you are familiar with py2exe. I am having a bit of a problem. See the program has a few pictures involved and the .ico it uses for the windows. However, the pictures are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.