Is it possible to have differently colored lines i

2019-06-21 22:03发布

问题:

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?

回答1:

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.



回答2:

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.



回答3:

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.