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

回眸只為那壹抹淺笑 提交于 2019-12-12 10:43:58

问题


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.



来源:https://stackoverflow.com/questions/8957981/is-it-possible-to-have-differently-colored-lines-in-multiline-text-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!