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:
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
cellToolTip in my code is an Inbox ToolTip. It too has the overload(s) for specifying a Point.
What I was missing was cell.GetUIElement().Rect. That was exactly what I needed. That allowed me to base the tooltip location on the top-left corner of the grid and offset it by ActiveCell.GetUIElement().Rect.Left and ActiveCell.GetUIElement().Rect.Bottom, effectively placing the tooltip right beneath the active cell. PERFECT!
What is cellToolTip in this example?Is it an Inbox tooltip or an UltraToolTip?
I thought the Inbox tooltip class has an overload of the show method that allows you to specify a point or a rect. If not, then you should use the UltraToolTipManager - this definately has an overload that allows you to specify the location of the tooltip.
Either way, you have to use the grid as the control here. You can get the location of the cell within the grid using the cell.GetUIElement().Rect.