在用textbox时,实现一些信息追加时,要使滚动条始终呆在最下面的实现方法。

textbox1为例,事件TextChanged中执行以下代码即可

private void textBox1_TextChanged(object sender, EventArgs e)
{
this.textBox1.SelectionStart = this.textBox1.Text.Length;
this.textBox1.SelectionLength = ;
this.textBox1.ScrollToCaret();
}
textBox1.Text=textBox1.Text+"内容"+Environment.NewLine;

那么你会发现,效果要闪瞎你的眼。。

textBox1.AppendText("内容"+Environment.NewLine);

效果是不是很完美啊?
注:Environment.NewLine默认换号符。

04-26 17:17
查看更多