0

I Want add images to my dataGridView columns, but i cant find the way to reference my image, or .ico inside of my project.

how i do this reference to inside the project, the path. I want generate my dll with my images.

Example:

private void createGraphicsColumn()
{
Icon treeIcon = new Icon(this.GetType(), “????????”); // this dude
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
iconColumn.Image = treeIcon.ToBitmap();
iconColumn.Name = “Tree”;
iconColumn.HeaderText = “Nice tree”;
dataGridView1.Columns.Insert(2, iconColumn);
}

https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/how-to-display-images-in-cells-of-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8

i tried a Directory.GetCurrentDirectory(), but they only catch the global path of the desktop. i want reference my project, without pass thrgouth the windows path.

  • 1
    That would not be a datagridView problem. Try searching for "image file refference in project c#" - https://stackoverflow.com/questions/53105594/c-sharp-reference-a-file-in-the-project. For future debugging you could help yourself by breaking down your problem and ask for a more specific question. – RatzMouze Dec 16 '22 at 13:27

0 Answers0