Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / display tooltip on mouse hover in cell

display tooltip on mouse hover in cell

New Discussion
aris
aris asked on Feb 1, 2010 10:27 PM

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

 

Sign In to post a reply

Replies

  • 0
    Jorge
    Jorge answered on Oct 14, 2008 2:50 PM

     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());
                }
            }

  • 0
    Mike Saltzman
    Mike Saltzman answered on Oct 14, 2008 3:15 PM

    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. 🙂

    • 0
      Vern
      Vern answered on Oct 28, 2008 6:52 PM

       Mike, using the MouseEnterElement and MouseLeaveElement approach, can one introduce a tool tip delay i.e. it takes some time before the tool tip shows? Would one just sleep for a few millisecond and then cause the tooltip to show?

      • 0
        Mike Saltzman
        Mike Saltzman answered on Oct 29, 2008 2:46 PM

        Well, if you use the ShowToolTip method, then the tooltip will show up immediately.You could use a Timer to introduce a delay, I suppose.

        Another option would be to change the ToolTip on the control based on the location of the mouse. You would do this using the UltraToolTipManager.GetUltraToolTip method. And then you can set properties on the UltraToolTip settings for that control. This way the UltraToolTipManager would handle the delay for you.

      • 0
        Vern
        Vern answered on Oct 31, 2008 8:00 AM

         Mike,

        Two questions regarding two unrelated requirements:

        – I have a column with icons displayed representing some underlying values. I would like a tooltip on the icon to say what it means (eg: red dot – status trouble, green dot- status fine, etc) What is the best approach to do this? Is there a way to tell the tooltipmanager that I want tooltip for a complete grid column and tell it what the various tooltips are for each underlying values of icon?

        – Unrelated to the above question, I have another requirement to show tooltip for each cell but with a delay. I found from previous posts that it is possible to set tooltip on individual cells using the tooltip property but it shows without delay. For getting the delay, based on your suggestion, I would need to use the ToolTipManager

            a) what control would I associate the tooltipmanager with

            b)  To set the tooltip value, I have to trap the mouse enter event, find the underlying cell and set the tooltip value?

         

         Thanks!

      • 0
        Mike Saltzman
        Mike Saltzman answered on Nov 3, 2008 3:00 PM

        [quote user=”vrn”]- I have a column with icons displayed representing some underlying values. I would like a tooltip on the icon to say what it means (eg: red dot – status trouble, green dot- status fine, etc) What is the best approach to do this? Is there a way to tell the tooltipmanager that I want tooltip for a complete grid column and tell it what the various tooltips are for each underlying values of icon?[/quote]
        What you would do is trap the MouseMove event of the grid and determine which cell the mouse is over. Then you would set the text on the ToolTip for the grid based on the location of the mouse. This is pretty much how tooltips work for every control. The tooltip is associated with the entire control, so if you want different tooltips for different areas, you have to change the tooltip as the mouse moves.
        [quote user=”vrn”]
        a) what control would I associate the tooltipmanager with
        [/quote]
        The UltraGrid control.
        [quote user=”vrn”]
        b)  To set the tooltip value, I have to trap the mouse enter event, find the underlying cell and set the tooltip value?
        [/quote]You would use the MouseMove event. Or maybe MouseEnterElement. Then you have to determine what the mouse is over. You do this using the ElementFromPoint method.

      • 0
        Vern
        Vern answered on Nov 4, 2008 9:00 AM

        [quote user="[Infragistics] Mike Saltzman"]You would use the MouseMove event. Or maybe MouseEnterElement. Then you have to determine what the mouse is over. You do this using the ElementFromPoint method. [/quote]

        Is it a problem if a set of  related grids share an instance of the tooltipmanager?

      • 0
        Mike Saltzman
        Mike Saltzman answered on Nov 4, 2008 4:33 PM

        No, not at all. The ToolTipManager can handle any number of controls. You just need to make sure that you are setting the tooltip on the right grid control. 

      • 0
        Vern
        Vern answered on Jun 14, 2009 11:53 PM

        Mike,

        You said

        [quote user="[Infragistics] Mike Saltzman"]

        Well, if you use the ShowToolTip method, then the tooltip will show up immediately.You could use a Timer to introduce a delay, I suppose.

        Another option would be to change the ToolTip on the control based on the location of the mouse. You would do this using the UltraToolTipManager.GetUltraToolTip method. And then you can set properties on the UltraToolTip settings for that control. This way the UltraToolTipManager would handle the delay for you.

        [/quote]

         

        It worked but  I get a tool tip to show ONLY the first time I enter a cell in that Grid. After that the only way to make the tooltip show is to either hover over outside that Grid and re-enter. Another way (little weird) is to click on another row in the same Grid and then hover over some cell. Those are these only two casesThe debugger tells me the MouseEnterElement handler is being invoked each time I hover over to a new cell.

        On MouseEnterElement:

        this.ultraToolTipManager1.InitialDelay = 500;           
        Infragistics.Win.UltraWinToolTip.UltraToolTipInfo toolTipInfo = this.ultraToolTipManager1.GetUltraToolTip((UltraGrid)sender);
        toolTipInfo.ToolTipText = "hello"; // cell specific information here
        //this.ultraToolTipManager1.ShowToolTip((UltraGrid)sender); 

        If I uncomment  the ShowToolTip method call above, I get the tooltip to show for each cell immediately as soon as I enter that cell.

        What am I doing incorrect?

        Thanks!

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jun 15, 2009 4:07 PM

        There's a sample included with the NetAdvantage SDK that does exactly what you are trying to do.

        Samples\WinMisc\CS\ToolTipManager\ToolTips with Context CS

        The sample uses a base class with a method called PrepareTooltip and then derives a class for the grid that overrides this method. So you could copy these two classes into your application and then just handle the PrepareToolTipMethod on the "ToolTipContextHelperForGrid" class.

      • 0
        Chan
        Chan answered on Feb 1, 2010 10:19 PM

        Sorry I'm new to Infragistics, where can I find the "samples" folder   ? 

      • 0
        Chan
        Chan answered on Feb 1, 2010 10:27 PM

        I just found it, thank you  Mike

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
aris
Favorites
0
Replies
13
Created On
Feb 01, 2010
Last Post
16 years ago

Suggested Discussions

Created by

Created on

Feb 1, 2010 10:27 PM

Last activity on

Feb 20, 2026 11:47 AM