Auto Scrolling Controls

Submitted by:David Villa

Date added:06 October, 2012

Category:VB.NET

Tested on multiline textbox and listview.

Tags: scrolling control

Code Snippet:

    #Region " Auto Scrolling"
<DllImport("User32.dll", CharSet:=CharSet.Auto, EntryPoint:="SendMessage")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function

Const WM_VSCROLL As Integer = 277
Const SB_BOTTOM As Integer = 7

Private Sub ScrollToEnd(ByVal obj As Object)
Dim ptrWparam As New IntPtr(SB_BOTTOM)
Dim ptrLparam As New IntPtr(0)
SendMessage(obj.Handle, WM_VSCROLL, ptrWparam, ptrLparam)
End Sub
#End Region
 
 

Comments