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
85
Toggle an image in WinGrid cell
posted

I have a data column that returns an index to an image in an ImageList.  I would like to display the appropriate image in the WinGrid column from the ImageList that contains the index.

Is there a way to set this in the display layout so that I don't have to cycle through each row of the dataset?

i.e.

myGrid.DsiplayLayout.Bands(0).Columns("ImageIndex").CellAppearance.Image = myImageList(????)

-or-

somehow assigned myImageList to myGrid.DisplayLayout.Bands(0).Columns("ImageIndex")? so that it shows the correct image from the list based on the column value?

In other words, I want to show an image in a cell based on a value rather than the value itself, but retain the value to be able to evaluate row events?

I would prefer not to have to cycle through every row of the table just to set this unless there is no other way.  If so, I will rethink my logic for deploying this feature.

Mark

  • 469350
    Suggested Answer
    Offline posted

    Hi Mark,

    What I would do is using the InitializeLayout event to add an unbound column to the grid to show the image. Then hide the column that has the value using the Hidden property.

    Then you would use the InitializeRow event to examine the value of the hidden cell and set the image on the unbound cell. InitializeRow is specifically designed for just the kind of thing you are trying to do.

    If you are concerned about efficiency, you should check out the WinGrid Performance Guide. There's an example in the guide about how to use the InitializeRow event and appearances most efficiently.