Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aarrrgh. How do I manipulate a Text box to..

Status
Not open for further replies.

Acidon

Programmer
May 1, 2004
21
Hello again.

I've been stuck on this way too long. I have no doubt that there is a simple solution, but it seems to be beyond me.

I have a Rich Text Box (but could use a Text Box if necessary) that fills with text periodically as per my App. When I add text data to the txtBox, I first append a new line "\n" and then append the text using +=. I'm assuming this isn't part of my problem, but there it is.

All I want is for the text box to stay scrolled to the bottom, featuring the newest text, leaving the ability to scroll up if necessary to review. And to not have the text box automatically move it down again when scrolled up to read something. Is this all possible at the same time?

I have a vertical scrollbar on it by default and I have Wordwrap enabled. Soo.. What I'm looking for is

1) The text box to always be scrolled down, showing the newest text. Currently it stays at the top showing the first things inserted as text is added below it.

2) The ability to scroll up and down reviewing text data without the text box moving the visible area unless i tell it to.

I don't know why can't seem to find this information, but I've spent way too long on a simple part of this App. Any information is greatly appreciated. Thanks! :)

Acidon
 
You could try something like:

RichTextBox1.AppendText(TheTextYouWantToAppend)
RichTextBox1.Focus()
RichTextBox1.ScrollToCaret()


Hope this helps.
 
Thank you for the reply,

That was one of the first things that I attempted and that does indeed work to keep the box scrolled to the bottom, but when I am scrolled up trying to read something it scrolls to the bottom whenever it appends text. This can obviously be quite annoying. :)

Now I'm wondering if there is a way to detect whether the vertical scrollbar is all the way down or not.. Is there a way to either get the position of the scroll bar or at least determine whether it's scrolled all the way to the top or bottom?

If so I could add that condition into the app.

if the scrollbar is all the way down
append
focus
scroll to caret
else
append


I will definately look into this. Your reply inspired this new line of thinking and for that I thank you. If you or anyone else knows something about scrollbars or anything else that would help me, please don't hesitate to reply :) Thanks again

Acidon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top