I have a combo which I use as an editor control in a grid's column. This combo has an EditorButton. I would like to show a tooltip when the user point the mouse over this button.
I have tried the solution found at http://community.infragistics.com/forums/p/59153/300694.aspx, but it does not work when the combo is used as an editor control (the MouseEnterElement is never invoked), although it works when it is on a form.
How can I show a tooltip in my case?
Thanks,
Emanuel
Hi Mike,
Following the sample you indicated I have found that there is an EditorButtonUIElement, and in it's context I have found the instance of the EditorButton (editorButtonUIElement.GetContext(typeof(EditorButtonBase)) as EditorButtonBase).
I've modified the code for the ToolTipContextHelperForGrid class (found in the sample):
- I have added a new method call in PrepareToolTip to PrepareEditorButtonToolTip;
- the code for the PrepareEditorButtonToolTip is:
private bool PrepareEditorButtonToolTip(UIElement element, UltraToolTipInfo toolTipInfo) { // See if the element is a EditorButtonUIElement EditorButtonUIElement editorButtonUiElement = element as EditorButtonUIElement; // if this is not a EditorButtonUIElement, return false. if (editorButtonUiElement == null) return false; // Get the EditorButtonBase from the EditorButtonUIElement EditorButtonBase editorButton = editorButtonUiElement.GetContext(typeof(EditorButtonBase)) as EditorButtonBase; // Set the Properties on the tooltip toolTipInfo.ToolTipText = "Add new child"; toolTipInfo.ToolTipTitle = "Add child"; toolTipInfo.ToolTipImage = ToolTipImage.Info; // Return true to indicate that a tooltip should be displayed when the // mouse is over this element. return true; }
Thank you for support!
I've attached a sample solution with my situation.
The combo is used as a editor control for the ChildId's column.
What I need to achieve is to display a tooltip when the user hovers over the ChildId column and the combo's editor button becomes visible.
Hi Emanuel,
So what exactly are you doing in the grid? The code in the sample you linked to is hooking the MouseEnterElement event of the combo. Obviously, that won't work if you are using a grid and not a combo, because the mouse will not be entering any elements in the combo. You would have to hook the MouseEnterElement event of the grid, instead.
You will, of course, also have to show the tooltip on the grid and not the combo. And you will probably want to trap MouseLeaveElement, also, so that you can clear the tooltip when the mouse leaves the button.
For a more complete implementation of something like this, you might want to check out the sample included with NetAdvantage called "Tooltips with Context". It's usually installed in a location something like this:
...\2011.1\Samples\WinMisc\CS\ToolTipManager\ToolTips with Context CS