WinForms中的自定义工具提示控件 [英] Custom tooltip control in WinForms
本文介绍了WinForms中的自定义工具提示控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种简单的方法可以在C#/WinForms中创建和显示自定义工具提示控件?
Is there a simple way to create and show a custom tooltip control in C# / WinForms?
我当前的想法是:
-
创建工具提示的子类,覆盖OnPaint方法,对其进行设置作为父控件的工具提示
create a subclass of Tooltip, override the OnPaint method, set it as the parent control's tooltip
创建表单的子类并显示手动
create a subclass of form and show it manually
有什么想法吗?
推荐答案
这取决于您所需的工具提示.如果您只需要具有气球形状,动画和淡入淡出效果以及自定义文本颜色和背景的工具提示,则使用工具提示控件会更容易
It depends on what you need for your tool tip. If you only need a tool tip with balloon shape, animation and fading effects with custom text color and background, It is easier to use ToolTip control
// 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);
这篇关于WinForms中的自定义工具提示控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文