dcsimg
Results 1 to 2 of 2

Thread: Automatically Auto Scroll Up and Down in Datagridview

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    1

    Arrow Automatically Auto Scroll Up and Down in Datagridview

    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.

    Name:  Sample.png
Views: 76
Size:  13.8 KB

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


    Code:
    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?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,294

    Re: Automatically Auto Scroll Up and Down in Datagridview

    You can set the FirstDisplayedScrollingIndex property to scroll the grid such that a specific row is at the top. You can call Rows.GetLastRow to get the last row in the grid and then use its Displayed property to check whether it is being displayed. Put those together with a bit of logic and you can scroll down by row until the last row is displayed and then scroll back to the top.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width