DataGridViewImageColum not showing images

0
0

I have a databound datagridview, with a colum of type DataGridViewImageColumn.

I want to show an image based on cell value.

I’m using DGV_CellFormatting event to assign a System.Drawing.Image as cell.Value, but nothing happens.

If I assing the same image resource to a button it shows up.

Could you please check my sampe code and help me figure out what’s wrong?

Thank you very much,

Jonatha

Attachment
  • You must to post comments
0
0

Hi Jonatha,

WJ-8322 and WJ-8323 are fixed in Wisej release 1.3.82.

Best regards
Frank

  • You must to post comments
0
0

Hi Jonatah,

See attached modified sample. There are a couple of issues:

  • The DGVImageCell only uses the value from the cell, it ignores the value set in the CellFormatting event. Logged as  WJ-8322.
  • But, the DGVImageCell inn Wisej has a double value type, like all images inn Wisej, it can be a string or a Bitmap. When setting a bitmap in CellFormatting it doesn’t match the FormattedType which is the same type as the value of the cell, but in your case that’s always null so it defaults to String, which is OK for image names.

In the attached modified sample I have included a DGVColumn override that is a temporary fix for WJ-8322. I also modified the sample to return the image path instead of the actual bitmap in CellFormatting. Using the bitmap in CellFormatting instead of a string is logged as an enhancement WJ-8323.

Using the image path is preferable on the web since it gives the browser a chance to cache the image and reduces the data transferred to the client. You may also make the images embedded resources instead of deploying them and prefix the image name with “resource.wx” -> “resource.wx/image.png” or the resource path “resource.wx/Resources.Images.image-name.png”, or the full assembly “resource.wx/MyAssembly.Resources.Images.image-name.png”.

In alternative you can assign the Bitmap to the cell value.

Both WJ-8322 and WJ-8323 should be completed soon.

HTH

/Luca

Attachment
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.