TextControl滚动条问题
问个简单的问题,TextControl如何默认滚动到最下面? 回复 1楼mindrayguowei的帖子问题正在调查中,有进一步结果反馈给您。 回复 1楼mindrayguowei的帖子
请查看以下代码能否满足你的需求:
private void Form1_Load(object sender, EventArgs e)
{
this.textControl1.Text = "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n";
scrollToTextPosition(this.textControl1.Text.Length - 2);
}
private void scrollToTextPosition(int textPosition)
{
Point newScrollLocation = textControl1.ScrollLocation;
newScrollLocation = new Point(0, textControl1.Lines.TextBounds.Y);
textControl1.ScrollLocation = newScrollLocation;
}
直接滚动到最后一行位置。
页:
[1]