Fábio Antunes
Fábio Antunes

Reputation: 17164

C# - Remove ToolTip only supplying in which Control is the 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);
    }
}

Upvotes: 4

Views: 9095

Answers (1)

t0mm13b
t0mm13b

Reputation: 34592

This should do it:

ToolTip.SetToolTip(TextBox1, null);

Upvotes: 10

Related Questions