有没有一种简单的方法在C# / WinForms中创建和显示自定义工具提示控件?
我的目前想法是:
创建Tooltip的子类,重写OnPaint方法,并将其设置为父控件的工具提示
创建Form的子类并手动显示它
有什么想法吗?
这取决于你需要的工具提示内容。如果你只需要一个带有气球形状、动画和淡入淡出效果的工具提示,以及自定义文本颜色和背景,那么使用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);