Scrolling textbox

wsyeager

Centurion
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
I'm using Windows Forms 2.0 (Visual Stduio 2005) and cannot get characters within the textbox to scroll. I need displays coming out because it is a batch process and need to allow operators of the app to view the messages.

I have the following code which I want to basically have show up in the window like so:

line1

line 2

etc.

<code>

TextBox1.Text = ControlChars.CrLf & "Retrieving Search Definitions along with their respective Search Criteria."

'do some processing

TextBox1.Text = ControlChars.CrLf & "Retrieved Search Definitions along with their respective Search Criteria."

</code>

I have the above type of code in several places in my app. Every time the textbox gets assigned a value, I perform the "Application.DoEvents()" method.

It's being written to the textbox, but is not available in the view. When another message comes along, it seems like it doesn't write it underneath the previous one, although other messages are coming out. It simply writes to the very first line in the textbox again.

I have the following pertinent properties set up for my textbox:

AcceptsReturn = True

AcceptsTab = True

Enabled = True

Locked = False

MaxLength = 0

MultiLine = True

ReadOnly = True

Scrollbars = Vertical

Visible = True

WordWrap = True

How can I get the characters in the textbox to appear underneath one another?
 
don't you just need a +=
TextBox1.Text += ControlChars.CrLf & "Retrieved Search Definitions along with their respective Search Criteria."

otherwise it will just overwrite the whole text?
 
jch001 said:
don't you just need a +=
TextBox1.Text += ControlChars.CrLf & "Retrieved Search Definitions along with their respective Search Criteria."

otherwise it will just overwrite the whole text?
Yes, that works fine... I should have thought about that one...

Is there any way to make the textbox automatically scroll down while the lines are being written out?

Since I have this form running on a thread, I can't readily move the scroll bar down to take a look at the line. It would also be a lot easier if it would just automatically scroll.
 
wsyeager said:
Is there any way to make the textbox automatically scroll down while the lines are being written out?
Something like this should work immediately after you update the text...
Visual Basic:
TextBox1.SelectionStart = TextBox1.Text.Length
TextBox1.ScrollToCaret()
 
Back
Top