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
875
Need location of UltraGridCell relative to UltraGrid for displaying tooltip when editing
posted

Hi,

I need to display a cell-oriented tooltip in two cases: (1) when the mouse hovers over a cell and (2) when the user begins editing a cell. I have the first case working just fine. However I'm having trouble getting the info I need to make the second case happen.

What needs to happen is as soon as a cell is entered for editing, I need to display the cell's tooltip (if any) directly below the cell. I'm calling the Show method on an internal System.Windows.Forms.ToolTip in an OnAfterCellActivate override for the grid to show the tooltip. The Show method takes (at a minimum) two arguments: the tooltip text to show and a Window to determine the relative location for the tooltip.

The problem is that I can't find a Window object that I can use for the base location for the tooltip:

  • I can't use ActiveCell since it isn't a window-based class. 
  • If I use ActiveCell.EditorControl as the Window argument (which I set just in the same override a few lines above) I never see the tooltip; maybe it's offscreen?
  • If I use "this" (the Grid) as the Window argument, I can see the tooltip but it's displaying relative to the grid's top left corner; I see no way to position it relative to the active cell.

Help. Is there any way I can get the active cell's X/Y offset within the grid? (And in such a way that works even if the grid is scrolled?) That would allow me to position the tooltip properly.

Here's the code that I'm using now. I can see the tooltip, but it's obviously always up at the top-left of the grid.

if (ActiveCell.ToolTipText == "")
    cellToolTip.Active =
false;
else
{
    cellToolTip.Active =
true;
    cellToolTip.Show(ActiveCell.ToolTipText,
this, 0, 0);
}

Thanks for your help!
Jim Honeycutt