The problem is that, the scrollbar by default stays on the topmost position whereas I want it to scroll down to the latest data coming in which is appended to the bottom of the richTextbox.
And if/when a user scrolls up to the middle position of the box, the scrollbar should NOT scroll to the latest data coming in. Instead, it should just stay on the position the user has scrolled up to.
How do I go about this?
Thanks. Im using C# btw.
8 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilanka DharmadasaPosted Jan 11, 2010, 1:26 AM
You can use the following.
richTextBox1.Select(richTextBox1.TextLength - 1, richTextBox1.TextLength);
richTextBox1.ScrollToCaret();
But you will need a few additional lines to do the exact thing. I wrote a small sample to do the exact thing that you want. Check it.
And please do not forget to tick 'Do you like this answer' check box.
Hiren SoniPosted Jan 11, 2010, 1:03 AM
Ika AJPosted Jan 12, 2010, 3:19 AM
However, should the user position back the scrollbar back to the bottom-most position, it still maintains that position instead of showing the latest data.
Nilanka DharmadasaPosted Jan 11, 2010, 6:10 AM
My solution works for textboxes except VScroll event. Textbox does not have an event as such. So why don't you use rich text box? If there is no special reason go for richtextbox.
Ika AJPosted Jan 11, 2010, 2:52 AM
Thank you so much for ur help!
Appreciate it so much.
Nilanka DharmadasaPosted Jan 11, 2010, 2:24 AM
That's what I have done in my code. Didnt you check it? Or is there any problem in that? let me know.
Ika AJPosted Jan 11, 2010, 2:05 AM
Lalit MPosted Jan 11, 2010, 12:37 AM
http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx