环境:c#+winform+vs2008
问题:在一个winform中放了一个TextBox,multiline=True。由于TextBox里边放了几千字的文本,所以想打开页面时就让TextBox慢慢滚动翻屏。  先感谢前辈了!

解决方案 »

  1.   

    增加一个timer
    在timer的tick中,设置TextBox.SelectIndex,每次为下一行的第一个字符位置。执行TextBox的ScoreToCaste方法。
      

  2.   

    [DllImport("user32.dll", EntryPoint = "SendMessage")]
      public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
            [DllImport("user32")]
            public static extern int GetScrollPos(IntPtr hwnd, int nBar);
            [DllImport("user32.dll")]
            static extern int SetScrollPos(IntPtr hWnd, int nBar,int nPos, bool bRedraw);
            public const int EM_LINESCROLL = 0xb6;
            private void timer1_Tick(object sender, EventArgs e)
            {
              int i=  GetScrollPos(this.textBox1.Handle,1);
                SendMessage(this.textBox1.Handle, EM_LINESCROLL, 0, 1);
                if (i == GetScrollPos(this.textBox1.Handle, 1))
                {
                    this.textBox1.SelectionStart = 0;
                    this.textBox1.SelectionLength = 1;
                    this.textBox1.ScrollToCaret();
                    this.textBox1.SelectionLength = 0;
                }
                Console.WriteLine(i);
            }
            private void textBox1_MouseEnter(object sender, EventArgs e)
            {
                this.timer1.Stop();
            }
            private void textBox1_MouseLeave(object sender, EventArgs e)
            {
                this.timer1.Start();
            }
    http://topic.csdn.net/u/20080516/16/ee1e0f44-ec0a-4f46-bd36-3cbb7ec2bf17.html
      

  3.   

    http://blog.csdn.net/jianuMan/archive/2010/06/19/5680535.aspx文本自动重复滚屏的例子