如何在TextBox的文本中更改一个句子的格式? [英] How to change a format of one sentece in a text in TextBox?

查看:167
本文介绍了如何在TextBox的文本中更改一个句子的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何更改TextBox中句子的格式?

例如以下文字:

"这是粗体字.
这是斜体文本.

Hi,
how can i change a format of a sentence in a TextBox?

for example in this text:

"This is a bold text.
This is a italic text.

This is a highlighted text!!!!

"

或我如何拥有一个文本容器,可以在其中更改特定文本的属性?类似于在Word文档中搜索.

"

or how can i have a text container that i can change the attributes of a specific text in it? something like searching in word document.

推荐答案

嗨!

对于C#/Windows应用程序:您无法在文本框中设置文本格式(即,将其设置为粗体,斜体,带下划线等).为此,最好使用RichTextBox

对于WPF:我不太确定,但我会在样式表(css)中做到这一点
Hi !

For C#/Windows Application : you cannot format text in a textbox (i.e. make it bold, italic, underlined, etc.). Better use RichTextBox for that purpose

For WPF : I''m not really sure but I would do that in a stylesheet (css)


您可以在WPF中使用RTB控件.

您可以在此示例中更改代码中运行的格式. [有关详细信息,请参见此处 [ ^ ]).

干杯.
You can use the RTB control in WPF.

You can change the formatting of runs in code as in this example[^]. You will have to compose paragraphs from "runs" and add them to the text box. Alternately, you could select pieces of text and apply formatting (see here for more[^]).

Cheers.


这篇关于如何在TextBox的文本中更改一个句子的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆