How can I sync the scrolling of two multiline textboxes?

后端 未结 5 462
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 07:57

How can I sync the scrolling of two multiline textboxes in C# (WinForms)?

When you scroll up/down a line in TextBox A, TextBox B should scroll up/down too. The same

5条回答
  •  [愿得一人]
    2020-11-30 08:30

    You can change this line:

    if (m.Msg == 0x115) && !scrolling && Buddy != null && Buddy.IsHandleCreated)
    

    to this:

    if ((m.Msg == 0x115 || m.Msg==0x20a) && !scrolling && Buddy != null && Buddy.IsHandleCreated)
    

    and it will support scrolling with the mouse wheel as well.

提交回复
热议问题