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
100
Ultragrid cell tooltip with icons
posted

Hello,

I need to create a cell tool tip, with Icons, the current cell displays 1 icon that could be different depending on business rules, so they want to tooltip to show a dictionary for these images, something like this:

Is it possible to extend the cell tool tip to do something like that?

  • 469350
    Offline posted

    Hi Jose,

    This can be done, but it's a bit tricky for a number of reasons.

    The grid doesn't have any built-in tooltip functionality for showing images like this. But the infrastructure is there, it's just not exposed directly by the grid.

    So there's a couple of issues here. First, you have to be able to show and hide ToolTips for only a single column of the grid. Normally, tooltips apply to an entire control. We have a sample included with the suite that shows you how to do this. If you have the samples installed, it will be under a folder something like: "..\2019.2\Samples\Legacy\Misc\CS\ToolTipManager\ToolTips with Context CS" Of course, your version and the exact location my vary.

    Anyway, the sample has a base class which handles a lot of the tedious stuff about showing a tooltip for some UIElements in a control and hiding it for others. And then you derive a class from the base class in the sample and override the PrepareToolTip method and check for cells in a particular column, set the tool tip properties you want, and return true or false to show/hide the tooltip.

    The second issue is showing images in a tooltip. To do that, you have to use the ToolTipTextFormatted property on the ToolTipInfo. And you will need to create some FormattedText (Xml) that has the images and the text you want.

    Since there's a lot of tricky stuff here, I whipped up a small sample project for you. This sample use the two class from the "ToolTips with Context CS" sample. It builds he xml for the Formatted tooltip, with the images. An it applies that formatted tooltip text to the "Element 1" column.

    The images I am using are of inconsistent size and they are kinda ugly, so I apologize in advance for that.

    Please let me know if you have any questions or any trouble getting this working.

    Tooltip With Images for WinGrid Column.zip