473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text Box - Move to last line.

I have a multiline text box that is about 20 lines longs. I have a timer that writes a message to it ever minute. What I want is to have the last line of the text box always displayed. Right now, you have to scroll down to get to see what was last updated. How do I do it autmomatically with my code?

Drew
Nov 16 '05 #1
5 18273
I had to figure this out a long time ago, and finally found a solution:

myTextBox.Selec tionStart = myTextBox.Text. Length;
myTextBox.Scrol lToCaret();

(I acutally put this in the TextChanged event of the textbox, so I never
have to worry about it)

HTH
-Cliff

"Drew" <Dr**@discussio ns.microsoft.co m> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a multiline text box that is about 20 lines longs. I have a timer that writes a message to it ever minute. What I want is to have the last
line of the text box always displayed. Right now, you have to scroll down
to get to see what was last updated. How do I do it autmomatically with my
code?
Drew

Nov 16 '05 #2
I haven't tested this, but I believe if you set the SelectionStart (or call
the Select() method) to the point where you want it to scroll and then call
the ScrollToCaret() method, that should do it.

Pete

"Drew" <Dr**@discussio ns.microsoft.co m> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a multiline text box that is about 20 lines longs. I have a timer that writes a message to it ever minute. What I want is to have the last
line of the text box always displayed. Right now, you have to scroll down
to get to see what was last updated. How do I do it autmomatically with my
code?
Drew

Nov 16 '05 #3
Thanks - that worked!

Drew

"Cliff Harris" wrote:
I had to figure this out a long time ago, and finally found a solution:

myTextBox.Selec tionStart = myTextBox.Text. Length;
myTextBox.Scrol lToCaret();

(I acutally put this in the TextChanged event of the textbox, so I never
have to worry about it)

HTH
-Cliff

"Drew" <Dr**@discussio ns.microsoft.co m> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a multiline text box that is about 20 lines longs. I have a timer

that writes a message to it ever minute. What I want is to have the last
line of the text box always displayed. Right now, you have to scroll down
to get to see what was last updated. How do I do it autmomatically with my
code?

Drew


Nov 16 '05 #4
Beware though, this will only work if the text box has focus.

The other fool-proof way is to use Win32 interop to send message with
WM_VSCROLL set to SB_BOTTOM.

-vJ

"Cliff Harris" <he***@myrealbo x.com> wrote in message
news:ed******** ********@TK2MSF TNGP09.phx.gbl. ..
I had to figure this out a long time ago, and finally found a solution:

myTextBox.Selec tionStart = myTextBox.Text. Length;
myTextBox.Scrol lToCaret();

(I acutally put this in the TextChanged event of the textbox, so I never
have to worry about it)

HTH
-Cliff

"Drew" <Dr**@discussio ns.microsoft.co m> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
I have a multiline text box that is about 20 lines longs. I have a timer

that writes a message to it ever minute. What I want is to have the last
line of the text box always displayed. Right now, you have to scroll down
to get to see what was last updated. How do I do it autmomatically with
my
code?

Drew


Nov 16 '05 #5
use AppendText() method
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10269
by: Charles Erwin | last post by:
Is there any way, upon scanning in a file line by line to avoid missing the last line if there is not a newline character (aka you have to hit return on the last line of input in your file). I was sure that there was a way around it but it escapes me if there is one. Thanks Charles Erwin
2
3990
by: Martin Dew | last post by:
I have a RichTextBox called rtbOutput. I am adding lines of text using the AppendText method. What I want to do is immediately after adding this line of text make sure that this line of text is displayed, effictively scrolling to the last line of the text box all the time. Can anyone help as I cannot seem to find a way to do this. Thanks
2
33948
by: Tarren | last post by:
Hi: I want to check my text file to ensure the last line has only DONE on it, prior to loading the file. How can I do this with a StreamReader object to go to the last line so I can perform the string comparison? Thanks
2
3813
by: Eric Lilja | last post by:
Hello, I'm writing a simple program that upon start-up needs to open a text file and read a value on the last line. Then all other accesses to the file will be writes (at the end of it). I'm having two problems with this...I tried opening the file for both writing and reading with: std::fstream file("budget.txt", std::ios_base::in | std::ios_base::out | std::ios_base::app); if(!file) std::cerr << "Error opening file!" << std::endl;
35
11408
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt", "r+"); fseek(file, -2, SEEK_END); fscanf(file, "%d", &c); this works fine if the integer is only a single character. When I get into larger numbers though (e.g. 502) it only reads in the 2. Is there
7
25907
by: DemonWasp | last post by:
I've been having some trouble getting the Scanner class to operate the way I'd like. I'm doing some fairly basic file IO and I can't seem to get the class to load the last line/token any way I try. First, I tried using the following: File InFile=new File("input.txt"); Scanner In=new Scanner(InFile);
6
5775
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line of entry in EOF while loop ? while (! file.eof() ) { ....
4
5956
by: Franky | last post by:
What I want to do is delete the last line in a RichTextBox. The RichTextBox has a ReadOnly property called lines that seems like it might help but I cant figure out how to use it. Well, the question is what is the easiest way to remove the last line in a RichTextBox? Thanks
1
918
by: BarryM | last post by:
Say if there is a bunch of writing in a text box and you want to change the first line to lets say "line 1" and the last line to "last line" but keep the lines in the middle the same text, how can i do this i had tried this but failed dim last_line as integer = txttext.lines.length -1 txttext.lines(0) = "line1" txttext.lines(last_line) = "last line"
0
8115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8053
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8513
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4007
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1638
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.