devN devN - 6 days ago 7
Vb.net Question

Move a listview Up/Down a form using the scrollbar of the Form VB.Net

My Form contains a Treeview, I would like for the treeview to move up and down the form with the scrollbar.

Here is a screenshot of the form.
The TreeView can be seen on the left hand side

I don't have any sample code regarding this as I am not sure where to begin

Any help is greatly appreciated
Thank You

The TreeView can be seen on the left hand side

Answer

I did some research on the topic and found myself a solution. Just gonna leave it here for anyone else with the same question.

'======================================
'TreeView Location Change with Scroll

Private Sub Form2_Scroll(sender As Object, e As ScrollEventArgs) Handles MyBase.Scroll
    'Gets the vertical scroll values as an Integer
    Dim verticalscroll As Integer = AutoScrollPosition.Y * -1
    'Moves the Treeview to new location
    EstimTree.Location = New Point(5, verticalscroll)

    'If statement to contain the treeview within my form       
    If EstimTree.Location.Y <= 130 Then
        EstimTree.Location = New Point(5, 130)
    End If
End Sub
Comments