VB.NET Richtextbox控件联动
两个Richtextbox控件(内容不同),如何实现托动其中一个控件的滚动条或鼠标时另一个Richtextbox控件的内容也随着同步移动。请各位高手帮助解决,要代码。谢谢!!
Public Class Form1 Const EM_LINESCROLL = &HB6 Private Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Public Function GetFirstLine() As Integer Dim point As System.Drawing.Point point.Y = 1 point.X = 1 Dim start As Integer = RichTextBox1.GetCharIndexFromPosition(point) GetFirstLine = RichTextBox1.GetLineFromCharIndex(start) End Function Private Sub RichTextBox1_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.VScroll RichTextBox2.ScrollToCaret() SendMessageBynum(RichTextBox2.Handle, EM_LINESCROLL, 0, GetFirstLine) End Sub End Class