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

徘徊边缘 提交于 2019-12-22 08:34:14

问题


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);
    }
}

回答1:


This should do it:

ToolTip.SetToolTip(TextBox1, null);


来源:https://stackoverflow.com/questions/2186105/c-sharp-remove-tooltip-only-supplying-in-which-control-is-the-tooltip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!