c# - C# 工具提示中的富文本

标签 c# winforms tooltip richtextbox

我可以扩展 ToolTip 并创建自己的 RichToolTip,但我不明白如何处理每行或每字的格式设置。我可以添加用户可以点击的控件吗?或图片等

我遇到了 RichTextBox但这是用 C++ (MFC) 编写的,我想要 C# 的东西或我可以与 C# 一起使用的东西。有什么建议么?有没有我可以使用的开源组件?

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

最佳答案

您可以使用 this HTML renderer .

关于c# - C# 工具提示中的富文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6459452/

相关文章:

c# - 我们如何通过代码在数据 GridView 上多选和删除多行?

c# - 当 "postback"使用 AJAX UpdatePanel 时,HiddenField 值属性变回空

c# - 如何以编程方式登录雅虎网站

javascript - 使工具提示图像与页面底部的光标对齐不同

jquery - 更改放置 Bootstrap 工具提示

c# - 将 IKVMC 生成的对象序列化为 JSON

c# - 如何在winforms的datagridview的当前单元格中添加椭圆按钮和文本框

c# - 编码UI : Why is searching for a cell so slow?

c# - 将 System.Drawing.Points 加在一起

Java SWT : show paintings in tooltip