kje999 0 Newbie Poster

I am trying to apply an automatic scrolling down and up in Datagridview Scrollbar. I've seen a related topic (using scrollbar panel) but I dont know how to convert for datagridview auto scrolling up and down.

I'll be using Timer for autoscrolling. Here is the code from another topics forum. Please help.

Private scrollUp As Boolean = False

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  If scrollUp Then
    Dim scrollY As Integer = -Panel1.AutoScrollPosition.Y - 1
    If scrollY < 0 Then
      scrollUp = False
    Else
      Panel1.AutoScrollPosition = New Point(Panel1.AutoScrollPosition.X, scrollY)
    End If
  Else
    Dim scrollY As Integer = -Panel1.AutoScrollPosition.Y + 1
    If scrollY > Panel1.AutoScrollMinSize.Height - Panel1.ClientSize.Height Then
      scrollUp = True
    Else
      Panel1.AutoScrollPosition = New Point(Panel1.AutoScrollPosition.X, scrollY)
    End If
  End If
End Sub

Here's what I want. From the top it will start to scroll slowly automatically then when the scrollbar reaches the bottom point then it will go back from the top and Scroll down again slowly and automatically. Another way to achieve it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.