views:

25

answers:

1

Let's say that I have a RichTextBox and its contents take up about 3 times the height compared to the visible height. There's no color formatting, I want to highlight keywords. If I use SelectionStart, SelectionLength and SelectionColor, then I have to set SelectionStart back to the caret's original position.

If, for example, I'm looking at the first page and my caret is half-way down the page, but I want a keyword highlighted near the end, when the caret is returned, the RichTextBox will only scroll up far enough for the caret to be on the top visible line, so my visible position has moved.

Is there any way for me to format colors out of view without affecting the view position? Or, is there any way for me to get and set/reset the view position after formatting?

A: 

The solution is here: "Get/Set the ScrollBars’ positions" http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx

After I return the caret to its original position with SelectionStart, I can use the code shown on the blog to return the view to its original position.

Dmi
Well done! Now, accept your own answer and get back to work! :)
kirk.burleson