Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Maintaining image display in WinGrid
posted

Hi -

I have a wingrid in which I'm displaying information about documents.  One of the columns in the grid is bound to the file system path of the document, and on the InitializeRow event of the grid I'm adding an icon image to the cell if the document path is not null:

e.Row.Cells[c_ImageLocation].Appearance.Image = Image.FromFile(@"icon.pdf.png");

The icon appears in the cell at runtime just fine, but when I click on the icon the text value of the cell is highlighted and displayed, and I don't want that.  I want to be able to reference the underlying text in order to send that path value to the code to open the document, but I don't want the text to appear to the user.

I've tried a few things to fake it out (font size and color, etc.), but it still shows up.

Is there a better/easier way to do what I'm trying to do?

thanks!

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    What I would do is use the InitializeLayout event of the grid to hide the column that contains the filename. Then, add an unbound column and set it's DataType to Bitmap.

    In the InitializeRow event, instead of setting the Appearance on this unbound column, you set the Value of the cell to your image.

    This provides you with a column that just has an image in it and no text.

Reply Children
No Data