C#Winforms帮助文本更改字体

时间:2016-04-14 21:19:20

标签: c# winforms

我有一个小帮助弹出窗口,当用户按下"?"时会显示一些文字。标签旁边的标签说明不同的选择。

我使用Help.ShowPopup命令完成它,因为这似乎是最简单的。

我希望有一种方法可以为文本的某些部分添加不同的字体属性,或者至少为整个事物添加不同的字体属性,而不必去CHM / HTML帮助文件的方向。

以下是我要做的事情:

private void helpLbl_Click(object sender, EventArgs e)
{
    // for some reason, it ignores the 'parent' parameter 
    // and lays it out on the screen's coordinates
    Point helpLocation = helpLbl.PointToScreen(Point.Empty); 
    helpLocation.Y += helpLbl.Height; // have it display underneath the control

    Help.ShowPopup(this,  // hosting form
@"<b>Fixed:</b>
Removes a fixed amount from the sale
<b>Percent Value:</b>
Removes a set percentage of the selected package from the sale
...", helpLocation);

我希望由于可以选择使用HTML文档来显示帮助,我可以使用HTML标记来格式化显示的内容,但它并不会出现。有任何想法吗?

有没有办法在帮助弹出窗口中显示RichTextBox?

另一种可能性是即时生成HTML文档,但它要求提供一个&#34; url&#34;如果我没有直接提供文本,我认为这可能会因为我试图在这里做的少量而过度杀戮。

1 个答案:

答案 0 :(得分:1)

您有两种选择。一种是使用WebBrowser Control。这本身接受HTML并显示它。它的问题在于它只是用作一个简单的标签。

您的第二个选择是简单地创建一个RichTextLabel,就像这样:

::operator delete[](arr)

将其添加到表单并将Rtf属性设置为您的RTF代码。您必须将HTML转换为RTF,例如,如果您有Microsoft Word等程序,这很容易。

相关问题