vb.net中两个RichTextbox的滚动条如何联动?
滚动个RichTextBox空间的滚动条时,另一个也跟着滚动。我曾用用SetScrollPos和GetScrollPos两个API函数实现了联动效果,但是只是滚动条联动,...
滚动个RichTextBox空间的滚动条时,另一个也跟着滚动。我曾用用SetScrollPos和GetScrollPos两个API函数实现了联动效果,但是只是滚动条联动,RichTextBox的内容不变,如果知道如何实现,请告知,急!(能实现追加200分)
这个例子我以前见过,曾经尝试着该成vb.net的,但是不行。vb.net的RichTextBox里没有Scroll的方法。 展开
这个例子我以前见过,曾经尝试着该成vb.net的,但是不行。vb.net的RichTextBox里没有Scroll的方法。 展开
3个回答
展开全部
Public Class Form1
Public Declare Function GetScrollPos Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nBar As Integer) As Integer
Public Declare Function SetScrollPos Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nBar As Integer, _
ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer
Private Sub RichTextBox1_HScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.HScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox1.Handle, 0)
SetScrollPos(Me.RichTextBox2.Handle, 0, lngPos, True)
End Sub
Private Sub RichTextBox1_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.VScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox1.Handle, 1)
SetScrollPos(Me.RichTextBox2.Handle, 1, lngPos, True)
End Sub
Private Sub RichTextBox2_HScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.HScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox2.Handle, 0)
SetScrollPos(Me.RichTextBox1.Handle, 0, lngPos, True)
End Sub
Private Sub RichTextBox2_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.VScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox2.Handle, 1)
SetScrollPos(Me.RichTextBox1.Handle, 1, lngPos, True)
End Sub
End Class
Public Declare Function GetScrollPos Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nBar As Integer) As Integer
Public Declare Function SetScrollPos Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nBar As Integer, _
ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer
Private Sub RichTextBox1_HScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.HScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox1.Handle, 0)
SetScrollPos(Me.RichTextBox2.Handle, 0, lngPos, True)
End Sub
Private Sub RichTextBox1_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.VScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox1.Handle, 1)
SetScrollPos(Me.RichTextBox2.Handle, 1, lngPos, True)
End Sub
Private Sub RichTextBox2_HScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.HScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox2.Handle, 0)
SetScrollPos(Me.RichTextBox1.Handle, 0, lngPos, True)
End Sub
Private Sub RichTextBox2_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.VScroll
Dim lngPos As Long
lngPos = GetScrollPos(Me.RichTextBox2.Handle, 1)
SetScrollPos(Me.RichTextBox1.Handle, 1, lngPos, True)
End Sub
End Class
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
难题啊!我回答不了,分数别浪费,给我吧o(∩_∩)o...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询