views:

3371

answers:

4

I have a 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 and I'm wondering what I'm 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");
+4  A: 

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.

HardCode
That would be Awesome!
Roberto Sebestyen
Actually I figured it out on my own, but I used your Idea.
Roberto Sebestyen
Great! Glad to have helped.
HardCode
And I thank you for your help
Roberto Sebestyen
This helped me out wrote a program on windows 7 and tried to run my tooltips on windows xp. After rebuilding my app with your tip it works just great. THX
MUG4N
+7  A: 

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.

Kevin
Yes - I too have this problem on XP machines but not Vista
Calanus
This works perfectly. In order to avoid manual event hooking, you can use code such as foreach (var label in Control.Controls.OfType<Label>()) label.MouseEnter += (s, ea) => { Main_Tooltip.Active = false; Main_Tooltip.Active = true; }; Also see http://stackoverflow.com/questions/1788490/c-how-can-i-iterate-through-all-checkboxes-on-a-form/1788757#1788757
ohadsc
+1  A: 

For what its worth I was having this problem on my 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 tooltip as needed within my code and they would all work.

If however if I tried to create all tooltips in code (say for instance in the formload event) the tips would only show once 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 alwasy include at least one VS tooltip control and then the rest within my code.

Silverwing
That's the difference between Apple and MS.. Apple appears to care about little things like this even if they are insignificant. Every little annoyance adds up and alienates users using your application.
Roberto Sebestyen
+3  A: 

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