如何在C#中使字符串的一部分变为粗体 [英] How to make part of string bold in C#
问题描述
大家好,
我想处理字符串就像字符串属性的一部分是更改
例如
我的默认字符串是
Hello Word
我想在桌面应用程序上向用户显示
H ell o W 或 d
请建议任何。
我尝试过:
1)
段落p = new段落();
p.Add(new Chunk(abc,FontStyle.Bold));
p .Add(new iTextSharp.text.Chunk(abc,FontStyle.Bold));
2)+ abc +;
3)@{\rtf1\ansi \b+ str +\ b0+ str1 +};
Hello all,
I want to work on string like the part of string property is changes
eg
My default string is
Hello Word
And i want to show to user on desktop application like
Hello Word
Please suggest any.
What I have tried:
1)
Paragraph p = new Paragraph();
p.Add(new Chunk(abc , FontStyle.Bold));
p.Add(new iTextSharp.text.Chunk(abc, FontStyle.Bold));
2)"" + abc + "";
3) @"{\rtf1\ansi \b" + str + "\b0" + str1 + "}";
推荐答案
有一个名为的控件: RichTextB ox(Windows窗体) [ ^ ]。使用它!
这是一个例子:如何:为Windows窗体RichTextBox控件设置字体属性Microsoft Docs [ ^ ]
There's a control which is called: RichTextBox (Windows Forms)[^] . Use it!
Here is an example: How to: Set Font Attributes for the Windows Forms RichTextBox Control | Microsoft Docs[^]
这篇关于如何在C#中使字符串的一部分变为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!