Hi Dayne!
My form has a richtextbox control with two button ("up" and "down") . I
need
to use those buttons to scroll the text in the richtextbox "page-by-page".
Any ideas?
it only works if the RTF-Box has the focus (and therefore a caret).
Here is a small example using WinAPI-SendMessage:
Imports System.Runtime.InteropServices
'SendMessage-Declaration
<DllImport("user32.dll")> _
Private Shared Function SendMessage( _
ByVal window As IntPtr, _
ByVal message As Integer, _
ByVal wparam As Integer, _
ByVal lparam As Integer) As IntPtr
End Function
'Constants for SendMessage
Private Const WM_VSCROLL As Integer = &H115
Private Const SB_PAGEUP As Integer = 2
Private Const SB_PAGEDOWN As Integer = 3
'ScrollDown-Button
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
'Let's add some text to the RTF-Box
For i As Integer = 0 To 100
RichTextBox1.Text += " Hello World "
Next
'One page down
SendMessage(RichTextBox1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0)
End Sub
'ScrollUp-Button
Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
'One page up
SendMessage(RichTextBox1.Handle, WM_VSCROLL, SB_PAGEUP, 0)
End Sub
Cheers
Arne Janning