0

Is it possible to do it? scroll all richTextbox in the same time with Vscrollbar. I have 8 richTextbox to do with it. Any idead of this?

Ps. Now, I've trying sync textbox class to sync textbox scroll https://stackoverflow.com/a/3823319/6811731 But it's seem doesn't work for me. Anyway, I decided to use vscroll instead.

Community
  • 1
  • 1
puydan
  • 37
  • 9

1 Answers1

2

Try something like this:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, ref Point lParam);

private const int EM_SETSCROLLPOS = 0x4DE;

private Point p;

private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
    p.Y = e.NewValue;

    SendMessage(richTextBox1.Handle, EM_SETSCROLLPOS, IntPtr.Zero, ref p);
    SendMessage(richTextBox2.Handle, EM_SETSCROLLPOS, IntPtr.Zero, ref p);
}
Jim
  • 2,974
  • 2
  • 19
  • 29
  • It did very goooooooood! Thank you :D – puydan Nov 10 '16 at 04:42
  • Are you employed now or studying? I'm studying in computer science but never seen code like this. When I'm starting co-operative education. They're many more than I thought. How do you know some kind of this code? – puydan Nov 10 '16 at 04:51
  • 1
    Good basic understanding, research, effort, experience and trying are probably the key. – Jim Nov 10 '16 at 05:12