1

我想编写一个代码,使我的 Richtextbox1 垂直滚动一行或一行。我怎样才能做到?谢谢大家。

4

1 回答 1

0
Public Const WM_VSCROLL As Integer = &H115
Public Const SB_LINEDOWN As Integer = 1
Public Const SB_PAGEDOWN As Integer = 3
Public Const SB_LINEUP As Integer = 1
Public Const SB_PAGEUP As Integer = 2

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown

If e.KeyCode = Keys.Down Then
  e.Handled = True

  SendMessage(Me.RichTextBox1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0)
ElseIf e.KeyCode = Keys.Up Then
  e.Handled = True

  SendMessage(Me.RichTextBox1.Handle, WM_VSCROLL, SB_PAGEUP, 0)
End If

 End Sub
于 2014-03-12T03:28:03.143 回答