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
80
Display images along with numbers and text in a cell?
posted

Hi. I have an ultragrid. The ultragrid will have text or numerics in it's cells. I am looking for a way to indicate that there is an attribute with a specific cell. For example, indicate to the user that the number in the cell has a note attached to it. 

I was thinking of dislaying an icon or image in the cell if that is possible. I've seen some other posts where it seems that you'd need to specify the entire cell to display an image.

Is there a way to add icon images to a cell while the cell has text or numerics in it? Or, is the a display style "trick" that I might use to indicate that a number in a cell has a note along with it? Any suggestions would be appreciated. Thanks

  • 469350
    Suggested Answer
    Offline posted

    Hi,

    There's nothing to it. :)

    What you do is handle the InitializeRow event. The event passes you the row, so you can examine the row and any cell values in it to determine what image (if any) or colors you want to apply to the row and any cells in that row.

    To apply an image to a cell, you simply do something like this:

    e.Row.Cells[columnKey].Appearance.Image = myImage;

    If you have a limited set of images, then a more efficient way to do this is to define an Appearance with an image up-front. Like in the InitializeLayout event of the grid you could add an Appearance to the layout's Appearances collection. Then you could re-use the same appearance on any cells that need it.

    e.Row.Cells[columnKey].Appearance = e.Row.Band.Layout.Appearance[myAppearanceWithAnImage];

    The latter technique is described in a little more detail in the WinGrid Performance Guide