Solved

Adding Image To Data Grid View Using Image List

Posted on 2009-05-05
2
2,384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

705 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