如何在文本框中逐行突出显示文本

问题描述:

如何使用c#.net

How to highlight the text backcolour in textbox line by line using c#.net

中逐行突出显示文本框中的文本背景色.问题未用UI标记.
Windows Forms中,TextBox 控件不支持为不同的行分配不同的BackColor .
为此,RichTextBox 控件在此处说明
http://msdn.microsoft.com/en-us/library/3tdc88y7.aspx [ ^ ]
可以使用.
但是,要突出显示文本的contiguous 块,可以使用TextBox SelectionStart SelectionLenth 属性,如此处所述
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectionstart.aspx [ ^ ]
The question is not tagged with the UI.
In Windows Forms, the TextBox control does not support assigning different BackColor for different lines.
For this purpose the RichTextBox control explained here
http://msdn.microsoft.com/en-us/library/3tdc88y7.aspx[^]
can be used.
However, to highlight a contiguous block of Text the SelectionStart and SelectionLenth properties of TextBox can be used as explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectionstart.aspx[^]