Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change background color of the certain line in the RichTextBox?

I want to change the color of the entire line, regardless of whether the text is there is or no. Here is some explaining image:

http://img131.imageshack.us/img131/1802/highlightlineqt2.png.

I found some solution here, but I hope that there is a simpler solution.

like image 423
Tenere Avatar asked Mar 01 '11 13:03

Tenere


1 Answers

No, you first have to select the line, then you have to set the color:

 public void MarkSingleLine()
 {
     int firstCharOfLineIndex = myRichTextBox.GetFirstCharIndexOfCurrentLine();
     int currentLine = richTextBox1.GetLineFromCharIndex(firstCharOfLineIndex);
     this.myRichTextBox.Select(firstCharOfLineIndex, currentLine);
     this.myRichTextBox.SelectionBackColor = Color.Aqua;
     this.myRichTextBox.Select(0, 0);
 }
like image 134
Anonym Avatar answered Nov 07 '22 19:11

Anonym