Is it possible to have differently colored lines i

2019-06-21 21:51发布

Is it possible to have differently colored lines in multiline text box?

I'm adding data to the text box and I want to clarify for the user different types of text by color.

How to do this if it's possible?

3条回答
放我归山
2楼-- · 2019-06-21 22:44

So depending on how you want the output, there's an browser/html control (basically a box), that you can pass a URL or a string of HTML, depending on what you're doing, you might want to use the RickTextBox - which has formatting commands - you could use regular expressions, or the offset of the text and then use a "set color" command on the text box with an IF structure.

查看更多
贪生不怕死
3楼-- · 2019-06-21 22:54

The standard Winforms textbox does not have this ability (and adding it would be troublesome).

You could look at using the System.Windows.Forms.RichTextBox as an alternative for this or one of the many commercial alternatives.

查看更多
不美不萌又怎样
4楼-- · 2019-06-21 22:55

You can do this if you use a RichTextBox control. See the documentation here (particularly look at the Remarks and Examples sections). The standard TextBox does not offer this capability.

查看更多
登录 后发表回答