Solved

Adding Image To Data Grid View Using Image List

Posted on 2009-05-05
2
2,293 Views
Last Modified: 2012-05-06
I want to add an image to the 6th column of the datagrid view..i tried the followinhg snippet..But i dont wanted to Give the path of the computer ..i know that we can ad an im age using image list ...how can i do that!
Dim dgImage As New DataGridViewImageColumn
            dgImage.HeaderText = "Delete"
            dgImage.Image = Drawing.Image.FromFile("C:\....\....\....\delete.gif")
            dgImage.ImageLayout = DataGridViewImageCellLayout.Normal
          
         TravelGridview.Columns.Insert(5, dgImage)

Open in new window

0
Comment
Question by:yuvaratna
  • 2
2 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24311239
Add an image to your form or usercontrol.

Configure the imagelist, add image you want..

Then to retrieve the image in the image list do the following


imagelist1.image(0)   '<--- This will load the first image in the imagelist...

0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 24311242
So, in your code it should be something like this:

Dim dgImage As New DataGridViewImageColumn
            dgImage.HeaderText = "Delete"
            dgImage.Image = imagelist1.image(0) 'retrieve the first image in the imagelist.
            dgImage.ImageLayout = DataGridViewImageCellLayout.Normal
         
         TravelGridview.Columns.Insert(5, dgImage)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question