如何在文本框中逐行突出显示文本
问题描述:
如何使用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.
InWindows Forms
, theTextBox
control does not support assigning differentBackColor
for different lines.
For this purpose theRichTextBox
control explained here
http://msdn.microsoft.com/en-us/library/3tdc88y7.aspx[^]
can be used.
However, to highlight acontiguous
block of Text theSelectionStart
andSelectionLenth
properties ofTextBox
can be used as explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectionstart.aspx[^]