Windows Forms ToolTip will not re-appear after first use

20,402

Solution 1

I had a similar problem today. Sometimes, the tooltip would not show. I had one ToolTip control for all the controls in my form.

I also had a MouseEnter event on all the controls added automatically, so I modified the MouseEnter event to do:

_tooltip.Active = false;
_tooltip.Active = true;

It fixed the bug, but I don't know why.

Also, the bug always happened on Windows XP machines, but not on Windows Vista.

Solution 2

I guess you'll be happy to know that Microsoft knows about it...since about 5 years...

  • 2/21/2005 Bug acknowledged as reproducable
  • 3/29/2005 Hum we might fix it, but later...
  • 11/15/2005 Well actually it's not a big bug, and it doesn't happen much, so we won't fix it.

Damn I love it when I stumble on bugs Microsoft doesn't want to solve! This time it's called a corner case, last time it was simply too difficult to resolve...

http://connect.microsoft.com/VisualStudio/feedback/details/115385/tooltip-stop-showing-after-autopopdelay

I'm off to tell my client that the bugs in my program are just corner cases and too difficult to resolve...

Solution 3

I had a similar problem today. VS 2010 SP1 .Net 3.5
After AutoPopDelay-Time the ToolTip do not show the Controls ToolTipText.
Kevins solution is the only way to solve the problem.

I encapsulate this in my own ToolTip class:

public class ToolTip : System.Windows.Forms.ToolTip 
{
    public ToolTip() : base() { }

    public ToolTip(System.ComponentModel.IContainer components) : base(components) { }

    public new void SetToolTip(System.Windows.Forms.Control ctl, string caption) 
    {
        ctl.MouseEnter -= new System.EventHandler(toolTip_MouseEnter);
        base.SetToolTip(ctl, caption);
        if(caption != string.Empty)
        ctl.MouseEnter += new System.EventHandler(toolTip_MouseEnter);
    }

    private void toolTip_MouseEnter(object sender, EventArgs e) 
    {
        this.Active = false;
        this.Active = true;
    }
}

Solution 4

I had this issue in VB.NET. What I did was drop a TooTip control on the form, and then on the target control's MouseHover event, I set the properties of the ToolTip. I did this because I used one ToolTip control for five different Label controls. It worked great. (Really, I wanted the ToolTip to show immediately, so I used the MouseEnter event instead.) I can post my exact code tomorrow when I get to work.

Solution 5

For what it's worth, I was having this problem on my Windows XP system until I noticed that if I placed at least one tooltip control on my form manually (from the toolbox) I could create as many tooltips as needed within my code, and they would all work.

If, however, I tried to create all tooltips in code (say for instance in the formload event) the tips would only show once and never to be seen again. I can't give you the exact "why this happens" story, but I have duplicated this issue several times always with the same effect. It might have something to do with the object scope, but I'm not sure.

So now just as a habit, I always include at least one Visual Studio tooltip control and then the rest within my code.

Share:
20,402
7wp
Author by

7wp

Twitter: 7wp

Updated on July 31, 2022

Comments

  • 7wp
    7wp almost 2 years

    I have a Windows Forms C# application where I would like to use a tooltip on one of the text boxes. I initialize the tool-tip in the constructor of the Form class, and it works the first time. So when I hover over the text box with my mouse it works, but once the toolTip times out and it goes away, it does not re-appear when I move my mouse away and back onto the control. I would expect it to come back. What am I doing wrong?

    Here is how I initialize the tooltip:

    myTip = new ToolTip();
    myTip.ToolTipIcon = ToolTipIcon.Info;
    myTip.IsBalloon = true;
    myTip.ShowAlways = true;
    
    myTip.SetToolTip(txtMyTextBox,"My Tooltip Text");