Rich Text in ToolTip for C#

徘徊边缘 提交于 2019-12-19 09:01:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!