I use textbox to write the results.
When textbox is multiline property set to true, and when I insert text into it,
I want it to auto scroll to the last line.
Here is a simple way to auto scrolling textbox.
textbox1.SelectionStart = textbox1.Text.Length;Textbox SelectionStart will force the textbox control to select the last part of the text,
textbox1.ScrollToCaret();
textbox1.Refresh();
and ScrollToCaret() function will auto scroll textbox to the end.
29 comments:
dosn't work :-(
Thanks, it's very useful
Thanks, it's very useful
Does not work if your TextBox is on another tab ( when using a TabControl )
working successfully, thx
Awesome solution!
It works for me. Thanks a lot for putting the solution in such a simple form!
-NRK
Works, thx
Thanks. It worked!
TextBox1.AppendText() works fater, not blinking and scroll text.
TextBox.AppendText() works awesome, and requires just 1 line of code! Thanks a lot!
at least for me this line was unnecessary:
textbox1.SelectionStart = textbox1.Text.Length;
Somebody suggested TextBox1.AppendText()
but I'm not sure it is designed for this purpose
have to test it and check if there are some drawbacks
muito bom.. obrigado
very good.. thanks xD
muito bom.. obrigadoo
very good.. thanks ;D
thx =)
works well, thanks.
tbPositionCursor.Select(tbPositionCursor.Text.Length, 0);
Easy as that...
>= .NET 3.0
Source: http://msdn.microsoft.com/en-us/library/ms752349.aspx
Many thanks
You can also use the built-in function for this..
textbox1.ScrollToEnd();
thanks it is very help full
Thanks, it's very useful
This is working but to avoid scroll bar flicker just use:
textBox.AppendText(myTextToAdd);
This is working but to avoid scrollbar flicker just use:
textBox.AppendText(myTextToAdd);
textBox.AppendText(myTextToAdd);
Will give error "Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: chunkLength" when myTextToAdd has large text... i.e. 2000 lines
There is no AppendText, nor ScrollToEnd on Compact Framework, Select doesn't seem to work, and authors proposition causes flickering of scrollbar :P
(GODDAMN CAPTCHA, 7th try)
Thanks a lot! This really helped me. It's strange that I wasn't able to find anything like this offered in Visual Studio 2008. Would be nice to have it in the properties menu of the text box.
İ love you man :)
My textBox is named "inputText":
inputText.AppendText(charTxt);
inputText.Select(inputText.Text.Length, 0);
inputText.Focus();
thank you very much
- max
Post a Comment