embedded image into DataGridViewImageColumn

KriZa

Member
Joined
Jun 22, 2007
Messages
21
Programming Experience
3-5
Hi,
I got a dataridview and I try zo create a datagridviewimagecolumn, but it doesn't work

my problem is to link to my embedded pictures.

my code:
VB.NET:
Imports System.Windows.Forms
Imports System
Imports System.Drawing

Public Class...

Public Function

Dim myIcon As New Icon(Me.GetType(), "C3.ico")
Dim iconColumn As New DataGridViewImageColumn()
With iconColumn
.Image = myIcon.ToBitmap()
.Name = "MyIcon"
.HeaderText = "MyIcon"
End With
KK.Columns.Insert(KK.Columns.Count, iconColumn)
end function
end class
an error occures following line: Dim myIcon As New Icon(Me.GetType(), "C3.ico")
means, he can't find the Icon at location: MyProject.Form1. My function is located in the form vb-code of 'Form1'. how do I have to navigate?
the C3 Icon is atm located directly in my mainproject. not in a subfolder or anything like that. i'd like to put it into the 'Resources' folder.

help needed, thx
 
Last edited by a moderator:
Right click on that icon file, select properties and set the build action to Embedded Resource.

Your profile shows you are using vb2005. If so, you can add icon (resources) using the Resources tab of the project properties window and you may access this icon(resource) as shown below.

for eg,
VB.NET:
Me.Icon = My.Resources.Icon1

Hope this will help you.
 
Back
Top