|
-
Apr 28th, 2003, 12:04 PM
#1
Thread Starter
Member
Automatically Scrolling to the bottom of a text box
Just outta curiosity, is there anyway i can get a text box to automatically scroll to the end when a text file is loaded into it? If i can get it to do that, then it'll make it alot more convenient for the people in my department that use the log viewer i made for my program. There's several thousand words in the file now.
How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny 
-
Apr 28th, 2003, 12:05 PM
#2
Hyperactive Member
yes, there is...
Just set the selection starting point to the end of the text...
VB Code:
Text1.SelStart = Len(Text1.Text)
"Experience is something you don't get until just after you need it."
-
Apr 28th, 2003, 01:19 PM
#3
Thread Starter
Member
I tried doing that, but it's not working when the form loads. But if i reload the text file, it does work. Is there a way to get it work when the form loads? I tried it in 2 different places:
VB Code:
Dim lngCharacters As Long
'Open log file for input so it can be loaded into the text
'field.
Open "G:\COMMON\AOPS\A-Ops Incidents Report\LOGS\Incident Report.txt" For Input As #1
txtLogComments.Text = Input(LOF(1), 1)
lngCharacters = LOF(1) / 8
lblCharacters.Caption = lngCharacters & " Words Loaded"
Close #1
'Automatically Scroll to the bottom of the text display
txtLogComments.SelStart = Len(txtLogComments.Text)
Thats the code from the form that actually has the text box on it. The other way i tried it is trying to do it from the form thats calling it which is the main form:
VB Code:
Load frmLogViewer
'Automatically Scroll to the bottom of the text display
frmLogViewer.txtLogComments.SelStart = Len(frmLogViewer.txtLogComments.Text)
frmLogViewer.Visible = True
Does anyone know why it doesn't work from the formload event? And how can i get it to work from the formload event? Thanks.
How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny 
-
Apr 28th, 2003, 01:24 PM
#4
PowerPoster
try refreshing:
VB Code:
txtLogComments.SelStart = Len(txtLogComments.Text)
txtLogComments.Refresh
-
Apr 28th, 2003, 01:35 PM
#5
Hyperactive Member
Originally posted by Muddy
try refreshing:
VB Code:
txtLogComments.SelStart = Len(txtLogComments.Text)
txtLogComments.Refresh
Hmm, good one, have to remember that one, don't know if it works though.
What you could do is place a timer on the form, set the interval to 1 microsecond and load the textboxt in it's event...
"Experience is something you don't get until just after you need it."
-
Apr 28th, 2003, 08:32 PM
#6
Frenzied Member
Make sure you have Shadows code in the Change sub of the textbox also.
-
Apr 29th, 2003, 03:40 AM
#7
Hyperactive Member
By the way, remember that the text control can not have unlimited amound of characters. It's limitation can be found in the help or MSDN...
If you put in more characters than it can handel you get an overflow...
"Experience is something you don't get until just after you need it."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|