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
170
display tooltip on mouse hover in cell
posted

Hello

how is it possible to read cell value and display tooltip on mouse hover in a grid .

i tryed the

Point mousePoint = new Point(MousePosition.X, MousePosition.Y);

UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(mousePoint);

UltraGridCell cell = element.GetContext(typeof(UltraGridCell)) as UltraGridCell;

 

if (cell != null)

{

MessageBox.Show(cell.Row.Index.ToString() + " " + cell.Column.Key);

}

 

but it does not work

  • 469350
    Verified Answer
    Offline posted

    My guess is that MousePosition returns you the position of the mouse in screen coordinates, not control coordinates. You can probably convert the coords using grid.PointToClient. Or you can use the MouseMove even and use e.X and e.Y. 

    Or, you could use grid.DisplayLayout.UIElement.LastElementEntered, instead of ElementFromPoint.

    Or, you could use MouseEnterElement and MouseLeaveElement, as suggested above. :)

  • 35
    posted

     Casually, there is another post where they suggest to do the following:

    //assuming you have a ToolTip control

     void grid_MouseLeaveElement(object sender, Infragistics.Win.UIElementEventArgs e)
            {
                toolTip.SetToolTip(poolGrid, null);
            }

            void grid_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e)
            {
                if (e.Element is EditorButtonUIElement)
                {
                    EditorButton button = e.Element.GetContext(typeof(EditorButton)) as EditorButton;

                    if (button.Tag != null)
                        toolTip.SetToolTip(grid, button.Tag.ToString());
                }
            }