Click here to Skip to main content
14,640,679 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
I am working on one application where i have to change the background color of a Rich text Box Text using Line Number. I have found the Line Number, but when i tried to color the respective text of that line number, its not effecting any thing there. My Code is as follows:

this.RTB.Select(this.RTB.GetFirstCharIndexFromLine(lineNumber), this.RTB.Lines[lineNumber].Length);
this.RTB.SelectionBackColor = Color.Red;


Please, suggest me what is wrong in this code.

Thanks

Shahab Abbasi
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

Please show me your RichTextbox Data............
In my case same code is working see here
int lineNumber = 2;
this.richTextBox1.Select(this.richTextBox1.GetFirstCharIndexFromLine(lineNumber),
this.richTextBox1.Lines[lineNumber].Length);
this.richTextBox1.SelectionBackColor = Color.Red;  
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100