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 wo
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.
I just had the the problem on Windows 7 so I found this thread.
In my case this did not work in tooltip_MouseEnter:
tooltip.Active = false;
tooltip.Active = true;
So I tried the following:
this.toolTip.SetToolTip(this.txtbx1, "tooltip-text");
This worked fine for me.
In my case after setting the tooltip text with the SetToolTip
method, I used the Show
overload with duration
parameter, i.e.
toolTip.Show(text, textEdit, 1000);
After that tooltip did not reappear on mouse hover, and resetting tooltip.Active
didn't work..
A workaround that worked for me was to use Show
overload without the duration, and hide it manually afterwards:
toolTip.Show(text, textEdit);
new Task(() =>
{
Thread.Sleep(750);
textEdit.Invoke(new Action(() => toolTip.Hide(textEdit)));
}).Start();
With this code I have the desired behaviour, i.e.
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
private void textBox_MouseHover(object sender, EventArgs e)
{
ToolTip1.Show("YOUR TEXT", textBox);
}
private void textBox_MouseLeave(object sender, EventArgs e)
{
ToolTip1.Active = false;
ToolTip1.Active = true;
}
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.
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;
}
}