WinForms中的自定义工具提示控件

有没有一种简单的方法来在C#/ WinForms中创建和显示自定义工具提示控件?

我目前的想法是:

  • 创建Tooltip的子类,重写OnPaint方法,将其设置为父控件的工具提示

  • 创建表单的子类并手动显示它

有什么想法吗?

这取决于您的工具提示所需的内容。 如果您只需要具有气球形状的工具提示,具有自定义文本颜色和背景的动画和淡化效果,则使用ToolTip控件更容易

// Create your control System.Windows.Forms.Button trialButton = new Button(); trialButton.Text = "Trial Button"; // Tool tip string string toolTipText = "Hello World"; // ToolTip toolTip = new ToolTip(this.components); ToolTip toolTip = new ToolTip(); toolTip.ToolTipTitle = "ToolTip Title"; toolTip.UseAnimation = true; toolTip.UseFading = true; toolTip.IsBalloon = true; toolTip.Active = true; toolTip.SetToolTip(button, toolTipText);