copyright 1999 - 2014 by heinz prelle - hannover  - lenbachstraße 42 - www.visual-basic5.de | impressum
Beispiel: VB .Net - MouseWheel - RichtextBox - Ohne Scrollbars scrollen
'

Option Explicit On
Option Strict On

Imports System.Runtime.InteropServices

Public Class Form1

    Private Sub RichTextBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
            Handles RichTextBox1.MouseWheel
        If e.Delta > 0 Then
            Win32Api.SendMessage(RichTextBox1.Handle, Win32Api.EM_SCROLL, Win32Api.SB_LINEUP, 1)
        Else
            Win32Api.SendMessage(RichTextBox1.Handle, Win32Api.EM_SCROLL, Win32Api.SB_LINEDOWN, 1)
        End If
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With Me
            .Text = "MouseWheel - RichtextBox - Ohne Scrollbars scrollen"
            .CenterToScreen()
            With Me.RichTextBox1
                .ScrollBars = RichTextBoxScrollBars.None
            End With
        End With
        For n As Integer = 0 To 100
            Me.RichTextBox1.Text &= n.ToString & ControlChars.CrLf
        Next
    End Sub
End Class

Public Class Win32Api

    <System.Runtime.InteropServices.DllImport("user32.dll")> _
    Public Shared Sub SendMessage( _
        ByVal hWnd As IntPtr, _
        ByVal uMsg As Int32, _
        ByVal wParam As Int32, _
        ByRef lParam As Int32)
    End Sub

    Public Const EM_SCROLL As Integer = &HB5
    Public Const SB_LINEDOWN As Integer = 1
    Public Const SB_LINEUP As Integer = 0

End Class
Sourcecode Visual Basic