爲了防止RichTextBox的反彈效應▲▼時豎線它在底部,你可以粘貼Class下到項目,並用它就像這個:
RichTextBox1.Select(RichTextBox1.TextLength - 1, 1)
If Not ScrollBarInfo.IsAtBottom(RichTextBox1) Then
RichTextBox1.ScrollToCaret()
End If
這是我從代碼修改後的版本在這裏提供:How to know if RichTextBox vertical Scrollbar reached the max value?的@景景
#Region " Scrollbar Info "
Public Class ScrollBarInfo
<System.Runtime.InteropServices.DllImport("user32")> _
Private Shared Function GetScrollInfo(hwnd As IntPtr, nBar As Integer, ByRef scrollInfo As SCROLLINFO) As Integer
End Function
Private Shared scrollInf As New SCROLLINFO
Private Structure SCROLLINFO
Public cbSize As Integer
Public fMask As Integer
Public min As Integer
Public max As Integer
Public nPage As Integer
Public nPos As Integer
Public nTrackPos As Integer
End Structure
Private Shared Sub Get_ScrollInfo(control As Control)
scrollInf = New SCROLLINFO()
scrollInf.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(scrollInf)
scrollInf.fMask = &H10 Or &H1 Or &H2 'SIF_RANGE = &H1, SIF_PAGE= &H2, SIF_TRACKPOS = &H10
GetScrollInfo(control.Handle, 1, scrollInf)
End Sub
' IsAtBottom
Public Shared Function IsAtBottom(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.max = (scrollInf.nTrackPos + scrollInf.nPage) - 1
End Function
' IsAtTop
Public Shared Function IsAtTop(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.nTrackPos = 0
End Function
' ReachedBottom
Public Shared Function ReachedBottom(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.max = scrollInf.nTrackPos + scrollInf.nPage
End Function
' ReachedTop
Public Shared Function ReachedTop(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.nTrackPos < 0
End Function
End Class
#End Region
看看這個: http://stackoverflow.com/questions/7518876/disable-scrolling-when-selecting-text-in -richtextbox-c – Jerry