Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set an infinite AutoPopDelay for a tooltip in a .NET Windows Forms window?

I have a requirement to not have the standard .NET Windows Forms 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 use specific MouseEnter and MouseLeave events for all controls with a tooltip. I'm happy to hear about third-party solutions if they'd solve the problem.

like image 931
Handleman Avatar asked Apr 30 '09 05:04

Handleman


People also ask

How do I use ToolTip in Windows Forms?

Set a ToolTip in the designerIn Visual Studio, add a ToolTip component to the form. Select the control that will display the ToolTip, or add it to the form. In the Properties window, set the ToolTip on ToolTip1 value to an appropriate string of text.

How many ToolTip objects are required on a Windows Form?

Add a ToolTip object to your form. One object is enough for the entire form.

What is ToolTip in C#?

In Windows Forms, the ToolTip represents a tiny pop-up box which appears when you place your pointer or cursor on the control and the purpose of this control is it provides a brief description about the control present in the windows form.

What is ToolTip in Visual Studio?

A tooltip is a small pop-up window that displays some information when you rollover on a control. In this article, I will discuss how to create and use a Tooltip control in a Windows Forms application using Visual Studio 2010. After that, I will discuss various properties and methods available for the Tooltip control.


3 Answers

As it has been posted countless times and is known from the .NET Framework early days, you cannot set the AutoPopDelay time higher than an Int16.MaxValue (i.e. 32767) and have it working. Using the tooltip Show() method leads to the same result. Any value higher than 32767 leads the timer to be reset to 5000 ms.

Even an attempt to set the AutomaticDelay to a value that leads to an AutoPopDelay value higher than 32767 will cause the tooltip not to work. Furthermore, using the StopTimer() method doesn't yield any positive results.

The only way I was succesful in displaying a tooltip with infinite timeout was using the tooltip Show() method that passes the displayed position. tooltip.Show(text, control, position). In conclusion, the tooltip control has the most bizarre behavior I have yet encountered in a control and the documentation about setting the delay times is quite misleading.

like image 175
Jimi Avatar answered Oct 10 '22 05:10

Jimi


I was searching for a solution to the problem

  1. The popup baloon disappears too fast, not allowing me to read its content
  2. The popup baloon does not appear again when hovering into that region.

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

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.

like image 21
panny Avatar answered Oct 10 '22 05:10

panny


In my application, the tooltip text has to update every 10 seconds. What works for me is to deactivate and activate the tooltip every time this text is updated. When I set the AutoPopDelay to more than 10 seconds, the tooltip will effectively stay forever. So you might use a timer to repeatedly activate and deactivate the tooltip:

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

To minimize the flicker that happens on reactivating the tooltip, set the InitialDelay to 1. When you set the AutoPopDelay to 30000 and the timer interval also to 30000 you'll see a very short flicker only once every 30 seconds. For my application this short flicker is acceptable. Btw, don't forget to turn on the timer! (At first I thought it didn't work, until I discovered I forgot to turn on the timer ;-))

Of course this is a cure for the symptoms and not an elegant solution to the problem.

like image 25
Bert Regelink Avatar answered Oct 10 '22 06:10

Bert Regelink