Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top