问题
I can extend the ToolTip and create my own RichToolTip but I don't understand how I can handle formatting per line or Per word. Can I add controls which a user can click on ? or images etc.
I came across RichTextBox but this is written in C++ (MFC) & I want something for C# or something which I can use with C#. Any suggestions? Are there any open source components which I can use?
public class RichToolTip : ToolTip
{
public RichToolTip()
{
this.OwnerDraw = true;
this.Draw += new DrawToolTipEventHandler(OnDraw);
}
public RichToolTip(System.ComponentModel.IContainer Cont)
{
this.OwnerDraw = true;
this.Draw += new DrawToolTipEventHandler(OnDraw);
}
private void OnDraw(object sender, DrawToolTipEventArgs e)
{
DrawToolTipEventArgs newArgs = new DrawToolTipEventArgs(e.Graphics,
e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText.Substring(0, 5),
this.BackColor, this.ForeColor, new Font("Arial Unicode MS", 8.25f, FontStyle.Bold));
newArgs.DrawBackground();
newArgs.DrawBorder();
newArgs.DrawText(TextFormatFlags.TextBoxControl);
}
}
回答1:
You can use this HTML renderer.
回答2:
This is the newer version of HTML renderer @SLaks - https://htmlrenderer.codeplex.com
来源:https://stackoverflow.com/questions/6459452/rich-text-in-tooltip-for-c-sharp