?
Solved

Adding Image To Data Grid View Using Image List

Posted on 2009-05-05
2
Medium Priority
?
2,490 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

850 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