Images in DatagridView - Path Source

0
1

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

 

  • You must to post comments
0
0

Hi Jay,

The right thing to do is to have your Images resources accessible throughout the app.

That way it could be accessible from anywhere, something similar to MyApp.Properties.Resources.myimage.

With Wisej.NET, there’s another way of loading images and that’s directly from the ImageSource property which would behave similarly to a website loading a ‘static image’ from the public folder, or using a URL.

You can find out more about the latter in our Documentation.

So, you have a few options:

  • Add the images to the Properties/Resource.resx file
  • Use Image.FromFile() method and have the file copied over to your output folder and make sure that it’s referenced correctly
  • The same this as above but also using the ImageSource property and directly referencing the file and/or URL if you want to go through that route!

I would also highly encourage that you check out our DemoBrowser Application, it’s Open Source and you can use it to see how any control can be used/configured and much more!

HTH,
Alaa

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.