简体   繁体   中英

Custom tooltip control in WinForms

Is there a simple way to create and show a custom tooltip control in C# / WinForms?

My current thinking is either:

  • 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

Any thoughts?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM