找回密码
 立即注册

QQ登录

只需一步,快速开始

mindrayguowei

中级会员

122

主题

274

帖子

986

积分

中级会员

积分
986

活字格认证

QQ
mindrayguowei
中级会员   /  发表于:2015-10-13 14:25  /   查看:3611  /  回复:2
问个简单的问题,TextControl如何默认滚动到最下面?

2 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2015-10-13 17:33:00
沙发
回复 1楼mindrayguowei的帖子

问题正在调查中,有进一步结果反馈给您。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-10-14 09:29:00
板凳
回复 1楼mindrayguowei的帖子

请查看以下代码能否满足你的需求:
  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             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";
  4.             scrollToTextPosition(this.textControl1.Text.Length - 2);
  5.         }
  6.         private void scrollToTextPosition(int textPosition)
  7.         {
  8.             Point newScrollLocation = textControl1.ScrollLocation;
  9.             
  10.             newScrollLocation = new Point(0, textControl1.Lines[textControl1.Lines.Count-1].TextBounds.Y);
  11.             
  12.             textControl1.ScrollLocation = newScrollLocation;
  13.         }
复制代码

直接滚动到最后一行位置。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部