Private Const SB_HORZ As Integer = &H0 Private Const SB_VERT As Integer = &H1 Private Sub SetTreeViewScrollPos(ByRef treeView As TreeView, ByRef scrollPosition As Point) Try SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_HORZ, scrollPosition.X, True) SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_VERT, scrollPosition.Y, True) If treeView.Nodes.Count > 0 Then Dim currentNode As TreeNode = treeView.SelectedNode currentNode.EnsureVisible() End If Catch ex As Exception End Try End Sub <DllImport("user32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _ Public Shared Function GetScrollPos(ByVal hWnd As Integer, ByVal nBar As Integer) As Integer End Function <DllImport("user32.dll")> _ Private Shared Function SetScrollPos(ByVal hWnd As IntPtr, ByVal nBar As Integer, ByVal nPos As Integer, ByVal bRedraw As Boolean) As Integer End Function
Justin Davis: How to control the scrollbar position in a Tree View Control:
'via Blog this'
No comments:
Post a Comment