richtextbox scrolling by code

  • Thread starter Thread starter Larry Hilley
  • Start date Start date
L

Larry Hilley

I have a richtextbox with a large amount of text in it that has scroll bars
to control what is in view.

I want to find text and then move it into view.

How do I control the document in the richtextbox so that when I find
something I want it display I can move it into view by code?

Thanks!

Larry Hilley
 
Larry,

You could move the caret to the position that you want, and then call
the ScrollToCaret method on the RichTextBox class. However, this has the
side effect of moving the caret (which you might not want).

You might also be able to send the WM_HSCROLL or WM_VSCROLL messages to
the textbox to force it to scroll to the appropriate position.

Hope this helps.
 
Hi!
That did help. From your comment I had to go find out how to move the
caret.
I found SelectionStart moves it. It looks like just moving the caret
also puts that text in view.

Thanks

Larry Hilley
 
Back
Top