C# – Controlling horizontal scroll in RichTextBox

crichtextboxwinforms

I have a RichTextBox that I'm spewing log information to, but the RichTextBox seems to want to horizontally scroll whenever text is appended that is too long to fit.

After searching extensively, and repeatedly failing with ScrollToCaret(), it would seem that this function controls the vertical scroll position, but not the horizontal. I have also attempted at using the API calls GetScrollRange() and SetScrollPos(), and while these do place the scrollbars in the right locations, they aren't controlling the actual location at which the RichTextBox is scrolled.

Best Answer

Could it be that there is no newline at the end of each log information in the log? use the System.Environment.Newline to append to the end of each line before putting it into the richtextbox. Take a look at this article on CodeProject which might help you and set you up in the right direction.

Hope this helps, Best regards, Tom.

Related Topic