Skip to content

DataGridViewImageColum not showing images #915

Closed

Description

@itg-assistant

Jonatha Panni asked 2017-06-23 14:56:41 UTC

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

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-06-23 17:46:49 UTC

    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

  2. added
    BugSomething is broken or behaving unexpectedly.
    on Jun 12, 2026
  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2017-08-13 22:28:02 UTC

    Hi Jonatha,

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

    Best regards
    Frank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions