C# 是否可以格式化工具提示文本(粗体、下划线...等)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/250774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 19:56:44  来源:igfitidea点击:

Is it possible to format Tooltip-Text (bold, underline... etc)?

c#winformsformattingcoding-styletooltip

提问by

I want to make some passages of a standard tooltip bold in a WinForms application. Is this possible?

我想在 WinForms 应用程序中将标准工具提示的一些段落加粗。这可能吗?

If not, is there a (free) tooltip component that allows me to style them (preferably also border and background)?

如果没有,是否有(免费)工具提示组件允许我设置它们的样式(最好还有边框和背景)?

Thanks!

谢谢!

回答by Patrick Desjardins

You can use this type : Balloon tool tip. This let you have some bold title and some color option. You might be able to modify the source to get underline, italic and bold inside the message.

您可以使用这种类型:气球工具提示。这让你有一些粗体标题和一些颜色选项。您可以修改源代码以在消息中添加下划线、斜体和粗体。

alt text

替代文字

Update:

更新:

You can modify the drawing of the ToolTip (and the FONT object of the text). This is how to do it. The code in this link is for the normal ToolTip, not the Balloon I posted above.

您可以修改 ToolTip 的绘图(和文本的 FONT 对象)。这是怎么做的。此链接中的代码适用于普通的 ToolTip,而不是我上面发布的 Balloon。

回答by user3141530

If you know a little about html, you can just write the tooltip like this:

如果你对 html 有一点了解,你可以像这样编写工具提示:

_toolTip.SetToolTip(button, String.Format("<font face=\"Microsoft Yahei\" color=\"blue\">{0}</font>", Tooltip Text));