Solved

Adding Image To Data Grid View Using Image List

Posted on 2009-05-05
2
2,209 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now