Geeks With Blogs

Arthur Zubarev Compudicted

Today I needed to make a text box auto scrolling in C#.

After reading all the relevant articles I cound find on the Internet I was still not able to get something that worked in my Windows Form and decided to experiment.

As a result, in 5 minutes later I produced the following code:

//Make the text box autoscroll

private void tbMessages_TextChanged(object sender, EventArgs e)
 

{

//Get the last text position
 

tbMessages.SelectionStart = tbMessages.Text.Length;

tbMessages.ScrollToCaret();

tbMessages.Refresh();

}

Posted on Wednesday, August 6, 2008 11:53 AM | Back to top


Comments on this post: How to make text box autoscroll

# re: How to make text box autoscroll
Requesting Gravatar...
Thank you. It works and it was easy:)
Left by Rasmus on Nov 26, 2008 3:36 AM

# re: How to make text box autoscroll
Requesting Gravatar...
Yeah that was easy, easier than i thought. Saved me time thanks man
Left by Randy Suzuki on Dec 23, 2008 7:16 PM

# re: How to make text box autoscroll
Requesting Gravatar...
thank u man :)))
Left by Gena on Jan 14, 2009 12:11 PM

# re: How to make text box autoscroll
Requesting Gravatar...
Many, many thanks, man!!! Much cleaner than posting messages to the control
Left by Kamen on Apr 06, 2009 6:49 AM

# re: How to make text box autoscroll
Requesting Gravatar...
There is an alternative way to set the AutoScroll Property of the Form to True. You will notice that any thread or another function appending text to the textbox will result in autoscrolling :-)
Left by Prashant Kumbhat on Apr 16, 2009 4:46 PM

# re: How to make text box autoscroll
Requesting Gravatar...
Thank buddy ..
Left by Jayesh on Jun 09, 2009 9:15 PM

# re: How to make text box autoscroll
Requesting Gravatar...
thanx nice one ! im gonna use it on my project..
Left by Emre Ozcelikel on Jun 12, 2009 2:14 AM

# re: How to make text box autoscroll
Requesting Gravatar...
THANKS! =D
Left by toloachero on Sep 07, 2009 4:03 PM

# re: How to make text box autoscroll
Requesting Gravatar...
Works great. Thanks a lot.
Left by Jigo on Oct 01, 2009 2:39 PM

# re: How to make text box autoscroll
Requesting Gravatar...
thx :)
Left by Ameet Parse on Oct 19, 2009 5:58 AM

# re: How to make text box autoscroll
Requesting Gravatar...
It's not working if the textbox is it on tab control,and not visible.
Left by Halil on Apr 22, 2010 4:02 AM

# re: How to make text box autoscroll
Requesting Gravatar...
Hello Halil,
can I ask you a question why you need a text box auto-scrolling if it is not visible?
Also it would be nice if you could share some relevant code, this way I should be able to assist you in a more effecient manner.
Left by Arthur on Apr 22, 2010 10:21 PM

# re: How to make text box autoscroll
Requesting Gravatar...
Tkx a lot
Left by Milton on Jun 18, 2010 1:31 PM

# re: How to make text box autoscroll
Requesting Gravatar...
I'm really glad that someone invented internet. I seriously wouldn't be able to write a single piece without people like you, thank you!
Left by Adam Czarny on Dec 30, 2010 8:37 AM

# re: How to make text box autoscroll
Requesting Gravatar...
If you want text to scroll vertically, you can also use a control like the one created at http://www.blackbeltcoder.com/Articles/controls/a-scrolling-status-control.
Left by Jonathan Wood on Feb 08, 2011 10:40 PM

# re: How to make text box autoscroll
Requesting Gravatar...
thank you
Left by mohammad hosein on Jul 09, 2011 4:16 PM

# re: How to make text box autoscroll
Requesting Gravatar...
Thanks so much!
Left by Kassy on Nov 03, 2011 12:25 PM

# re: How to make text box autoscroll
Requesting Gravatar...
textBox.ScrollToEnd()

:)
Left by Wadashe on Mar 05, 2013 10:25 AM

Your comment:
 (will show your gravatar)


Copyright © Compudicted | Powered by: GeeksWithBlogs.net