views:

861

answers:

7

I have a requirement to not have the standard .net winform tooltip automatcially hide - that is, I need them to remain visible until the mouse moves off the control that has the tooltip. I'd like to avoid having to specific MouseEnter and MouseLeave events for all controls with a tooltip. I'm happy to hear about 3rd party solutions if they'd solve the problem.

A: 

Why don't you set the ToolTipService.ShowDuration attached property to int.MaxValue?

<Button 
  Height="23" Width="75"
  Content="Click Me" 
  ToolTip="My ToolTip" ToolTipService.ShowDuration="2147483647" 
/>
M. Jahedbozorgan
I need this for a desktop application, so there is no markup (and no property of the ToolTip called "ShowDuration".
Handleman
Sorry, it seems that I didn't pay attention to the winform part! This is for WPF.
M. Jahedbozorgan
+1 I was looking for this in WPF! Thank you!
A: 

The ToolTip.StopTimer method might help. From MSDN:

The ToolTip class has an internal timer that it uses to set the display duration for ToolTips. The duration associated with this timer is set through the AutoPopDelay property. The StopTimer method will stop this internal timer, causing any displayed ToolTip to be shown modally until the Hide method is called, or the parent form is minimized, hidden, or closed.

Tim Robinson
I can't see a method on the ToolTip for StopTimer. This is for a windows form desktop application. Do you have the MSDN refrence?
Handleman
assume you mean this page - http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.stoptimer.aspxThis seems to be a private method so I'm not sure how I can execute it...? Do I then have to manage the Hide call from the MouseLeave event for each control?
Handleman
It's protected, so I think you can subclass the ToolTip control, handle the Popup event, and call this method from there.
Tim Robinson
A: 

This is not going to be the answer you want to hear... Roll your own. I once had scenario where I wanted to simulate the new Office's ribbonbar tooltip behavour for shortcut keyboard commands and I found that the standard tooltip API is just too limited.

Make a small, simple and border-less form instance for every control that you need a tooltip for. Then show and hide them non-modally as you do a mouse-enter or -leave event. Have the constructor for this window receive the UI control instance and let it query the control for it's events so that it can attach itself to the mouse-enter and -leave events, so that you wouldn't have to wire them up manually.

Pieter Breed
Was really hoping that wasn't the answer. I think if I had to do this I'd have one form (or even label) that I would float over the top using MouseEnter/Leave and populate with the appropriate text at runtime. Was hoping to avoid it ... but may not be able to.
Handleman
A: 

So, I ended up de-activating the tooltip, but still using it to hold the text for the tooltip because it neatly adds itself to all the controls. I made my own panel and label inside it for the tooltip and dynamically positioned, made visible and populated the text on the mouse enter and mouse leave events of all the controls.

I also wrote a recursive function to add the mouse events to each label control (the only ones I have tooltips on) so I didn't have to manually to it and won't have to remember to do it when I add a new label. New developers on the project may not ever realise that the tooltip control is not actually rendering the tips.

Why a label in a panel? - so really big tooltips can scroll - although this is still not working nicely.

Not real pretty, still looking for a good answer if you've got on (or a critique of the method I've employed).

Came across http://www.binarymission.co.uk/ but their tooltip did not seem to render properly in my .net 3.5 app. Still talking to them.

Handleman
A: 

try myToolTip.ReshowDelay = 0.

You just reshow immediately the tooltip after its delay expires. It worked for me.

serhio
A: 

I was searching for a solution to the problem

'the popup baloon disappears too fast, not allowing me to read its content (Problem1) and does not appear again when hovering into that region (Problem2)',

I found in the forums the following answer, which does not solve Problem2, but lets me read the text for more than the time I need when I set its value to 32766 and is thus - in my opinion - a kind of 'work around':

" Actually, I found out my problem was that I assigned a value higher than 32767 (32768 and higher will have an effect of 5 sec) really weird, since AutoPopDelay is supposed to take an Integer (32 bit) as parameter, and 32767 is really a signed 16 bit ..."

from: http://dotnet.itags.org/dotnet-visual-basic/23325/

But I have to admit, it still sucks...

But setting it to 32000 (32 seconds) seems to work better. No clue why this is but maybe it helps someone.

panny
+1  A: 

I think you are trying to cure the symptoms and not the cause of your problem.

You are trying to force a ToolTip to be something different from a ToolTip. A tooltip is, by definition, "a small "hover box" with information about the item being hovered over".

If the user can't read what the tooltip is trying to suggest in 30 seconds, then it isn't really a "tip" but an entire chapter from the help file. Put lengthy instructions into the Manual and do not attempt to force it into a ToolTip that stays open forever.

Happy coding!

Peter Perháč