mindrayguowei 发表于 2015-10-13 14:25:00

TextControl滚动条问题

问个简单的问题,TextControl如何默认滚动到最下面?

iceman 发表于 2015-10-13 17:33:00

回复 1楼mindrayguowei的帖子

问题正在调查中,有进一步结果反馈给您。

iceman 发表于 2015-10-14 09:29:00

回复 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]
查看完整版本: TextControl滚动条问题