How to make autoscroll multiline TextBox in WinForms? [duplicate]

不问归期 提交于 2020-01-12 06:38:12

问题


Possible Duplicate:
How do I automatically scroll to the bottom of a multiline text box?

I use a multiline TextBox to output some information in new lines as it arrives from a BackgroundWorker.

Can I make it to scroll to the very bottom each time a new line arrives?

By default it seems to do just the opposite - it scrolls to the very first line each time a new line arrives and the Text property is changed.


回答1:


Set the TextBox properties:

Multiline = True;
ScrollBars = Both;

To auto scroll on the TextChanged event:

textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();


来源:https://stackoverflow.com/questions/13505248/how-to-make-autoscroll-multiline-textbox-in-winforms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!