Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RichTextBox current line

Status
Not open for further replies.

miket26

Programmer
Apr 13, 2004
63
CA
Hi,

I am trying to get the text in a specific line in a Richtextbox. For example, I want change the font color for line 5 in a Richtextbox with 20 lines. I have a method to change the font color, but need to get the start and end position for that line. Anyone know a nice way to do this??

Thanks.
 
I would be tempted to use the GetLineFromCharIndex method inside a Binary Search, looking for the line# then subtracting 1 from the CharIndex until GetLineFromCharIndex returns the previous line.

Compare Code
 
Would you know a good way to scroll through the Richtextbox and look for \n, to determine the start and end position for the line? I've tried a few things, but none are working the right way. I'm also having trouble actually finding the carriage return.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top