0

I'm using Infragistics NetAdvantage 2010 in my Winforms application. This is the code for loading a custom tooltip on a button's mousehover.

private void button1_MouseHover(object sender, EventArgs e)
{
    UltraToolTipInfo toolTipInfo = ultraToolTipManager1.GetUltraToolTip(button1);
    toolTipInfo.ToolTipTextStyle = ToolTipTextStyle.Formatted;
    ultraToolTipManager1.DisplayStyle = ToolTipDisplayStyle.Office2007;

    toolTipInfo.ToolTipTextFormatted = "" +
        "<p style='color:Black; font-family:tahoma;'>Details:</p>" +
        "<p style='color:Black; font-family:tahoma;'>Name: <t style='color:Black; font-family:tahoma; font-weight:bold;'>Sandeep</t></p>" +
        "<t style='color:Black; font-family:tahoma;'>Profile: <t style='color:Black; font-family:tahoma; font-weight:bold;'>Developer</t></t> ";
}

But when I run this, the tooltip won't appear the first time when I do a mouse-hover. It starts coming from the second time onwards. What could be the problem here?

Sandeep
  • 5,581
  • 10
  • 42
  • 62
  • 1
    Might be an idea to put your code in a MouseEnter Event rather than mouse hover and see if that works. (you may need to then close the tool tip on a MouseLeave event on the button) – Ctrl_Alt_Defeat Mar 09 '12 at 08:26
  • I suppose you do all this stuff in MouseHover because you need some kind of dynamic info in your tooltip. However I don't see anything 'dynamic' in your string. – Steve Mar 09 '12 at 08:44
  • @Steve: It's doesn't look dynamic because that's just a sample string I've posted!! – Sandeep Mar 09 '12 at 09:31
  • Well, then I think that MouseHover is too late in the chaining of events to change the UltraToolTipInfo. I mean, when you receive the first mousehover the tooltip internal processing can't show the updated text. I will try with the suggestion of @KOL. Or try calling directly ShowToolTip. – Steve Mar 09 '12 at 09:39
  • @KOL: That works..! Wondering how Infragistics missed out this bug :) – Sandeep Mar 09 '12 at 10:58

2 Answers2

1

As my comment has worked will include it as an answer.

Change the code so the ToolTip loads on a MouseEnter Event rather than a MouseHover Event. (Note you may need to close the ToolTip on a MouseLeave Event.

Ctrl_Alt_Defeat
  • 3,933
  • 12
  • 66
  • 116
0

The UltraTooltipManager uses the MouseMove event of the control to determine when to show tool tips. The mouse hover happens after MouseMove and this is why you don't see the tool tip on the first mouse hover as the MouseMove has already happened. You can see more details on the order of mouse events on MSDN: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousemove.aspx

There are two solutions to correct this: 1. Move your logic to the MouseEnter as this will happen before the MouseMove and you will get the behavior that you desire. 2. Set the tool tip at the time when what should be displayed in the tool tip changes.

Which is a better approach will depend on how often users mouse over the control and how often changes are made to the information in the dynamic tool tip.

alhalama
  • 3,218
  • 1
  • 15
  • 21