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.
Hiren SoniRank #694 · 3.5K reputationPosted Jan 10, 2010, 8:03 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 10, 2010, 8:26 PM EST
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.
Lalit MRank #1,186 · 1.5K reputationPosted Jan 10, 2010, 7:37 PM EST
http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx
Ika AJ13 reputationPosted Jan 10, 2010, 9:05 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 10, 2010, 9:24 PM EST
That's what I have done in my code. Didnt you check it? Or is there any problem in that? let me know.
Ika AJ13 reputationPosted Jan 10, 2010, 9:52 PM EST
Thank you so much for ur help!
Appreciate it so much.
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 11, 2010, 1:10 AM EST
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 AJ13 reputationPosted Jan 11, 2010, 10:19 PM EST
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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts