Winform编程中,使用的Textbox控件,我们很有可能会遇到需要随时更新其内容(比如聊天窗口文字的更新),当内容过多的时候,就会出现滚动条,如何让滚动条时刻跟随内容的最下面内容呢?
private
void
TextBox_TextChanged(
object
sender, System.EventArgs e)
{
this .TextBox.SelectionStart = this .TextBox.Text.Length;
this .TextBox.SelectionLength = 0 ;
this .TextBox.ScrollToCaret();
}
{
this .TextBox.SelectionStart = this .TextBox.Text.Length;
this .TextBox.SelectionLength = 0 ;
this .TextBox.ScrollToCaret();
}
搞定。