Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a tooltip currently bound to a control?

I'm currently adding a tooltip to a label like so:

ToolTip LabelToolTip = new System.Windows.Forms.ToolTip();
LabelToolTip.SetToolTip(this.LocationLabel, text);

When I need to change this tooltip as the label's text changes, I try doing the same to add a new tooltip. Unfortunately, the old tooltip remains under the new one, which is really annoying. Is there a method to remove the old tooltip, or should I just make a new label when I want to change the text in a label?

like image 535
スーパーファミコン Avatar asked Jul 22 '09 14:07

スーパーファミコン


2 Answers

Create a single instance of the ToolTip and use it whenever you like to show it using the SetToolTip method and use Hide method to hide it. Generally it is not necessary to create more than one ToolTip instance.

like image 68
Vivek Avatar answered Oct 11 '22 15:10

Vivek


The tooltip object works in multiple Controls at the same time.

Create a single instance of the ToolTip and use it for adding and removing a ToolTip of any Control.

When adding you should simply use .SetToolTip(Control, "Message that will apear when hover") When removing you just set it back to null with .SetToolTip(Control, null).

like image 34
Pedro Farina Avatar answered Oct 11 '22 14:10

Pedro Farina