Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Remove ToolTip only supplying in which Control is the ToolTip

Tags:

c#

tooltip

Yes this question as already been asked here at SO.

The problem is that the solution for that question was hiding the tooltip, and i really need to remove not hide it.


I'm adding tooltips to several controls in my Form using a couple a functions i've made.

There are two functions, one to set the Tooltip to display on MouseHover, and another to show the Tooltip at all times.

Only one missing. One to remove any Tooltip that is been set or is being displayed by a specific control.

Something like

tooltip.remove(TextBox1);

Something that simple where i only need to set the Control where the tooltip is.

I've tried a couple things but didn't work.

Thanks.

EDIT:

This is how i use my code to add tooltips.

This was Coded the wrong way

My code to Set and Show Tooltips:

public class UserInterface
{
    public void SetTooltip(Control Object, string Message, string Title, ToolTipIcon icon, Boolean isBallon, Boolean showAlways)
    {
        ToolTip Tip = new ToolTip();
        Tip.UseAnimation = true;
        Tip.UseFading = true;
        Tip.ToolTipIcon = icon;
        Tip.IsBalloon = isBallon;
        Tip.ShowAlways = showAlways;
        Tip.ToolTipTitle = Title;
        Tip.SetToolTip(Object, Message);
    }

    public void ShowTooltip(Control Object, string Message, string Title, ToolTipIcon icon, Boolean isBallon, Boolean showAlways)
    {
        ToolTip Tip = new ToolTip();
        Tip.UseAnimation = true;
        Tip.UseFading = true;
        Tip.ToolTipIcon = icon;
        Tip.IsBalloon = isBallon;
        Tip.ShowAlways = showAlways;
        Tip.ToolTipTitle = Title;
        Tip.Show(Message, Object);
    }
}
like image 304
Fábio Antunes Avatar asked Dec 30 '22 03:12

Fábio Antunes


1 Answers

This should do it:

ToolTip.SetToolTip(TextBox1, null);
like image 151
t0mm13b Avatar answered Dec 31 '22 15:12

t0mm13b