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

前端 未结 6 1932
北荒
北荒 2020-12-20 12:12

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

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


        
6条回答
  •  遥遥无期
    2020-12-20 12:38

    To simply remove the tooltip from the control, you could modify the class like this:

    public static void SetToolTip( Control control, string text )
        {
            if ( String.IsNullOrEmpty( text ) )
            {
                if ( tooltips.ContainsKey(control.Name ) )
                {
                    GetControlToolTip( control ).RemoveAll();
                    tooltips.Remove( control.Name );
                }
            }
            else
            {
                ToolTip tt = GetControlToolTip( control );
                tt.SetToolTip( control, text );
            }
        }
    

    and use this command:

    ToolTipHelper.SetToolTip( control, "" )
    

提交回复
热议问题