VB.net DataGridView scrolling error

Murray Brown
Murray Brown used Ask the Experts™
on
Hi
I am using the code below to scroll four DataGridViews when my first DataGridView is scrolled. When I play around with it and click in the first DataGridView I get the error
"Specified argument was out of the range of valid values. Parameter name value"

      Try

            Me.DataGridView1.FirstDisplayedScrollingRowIndex = Me.DataGridView5.FirstDisplayedScrollingRowIndex
            Me.DataGridView1.HorizontalScrollingOffset = Me.DataGridView5.HorizontalScrollingOffset

            Me.DataGridView2.FirstDisplayedScrollingRowIndex = Me.DataGridView5.FirstDisplayedScrollingRowIndex
            Me.DataGridView2.HorizontalScrollingOffset = Me.DataGridView5.HorizontalScrollingOffset

            Me.DataGridView3.FirstDisplayedScrollingRowIndex = Me.DataGridView5.FirstDisplayedScrollingRowIndex
            Me.DataGridView3.HorizontalScrollingOffset = Me.DataGridView5.HorizontalScrollingOffset

            Me.DataGridView4.FirstDisplayedScrollingRowIndex = Me.DataGridView5.FirstDisplayedScrollingRowIndex
            Me.DataGridView4.HorizontalScrollingOffset = Me.DataGridView5.HorizontalScrollingOffset

        Catch ex As Exception
            MsgBox("Scrolling error " & ex.Message)
        End Try
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
And where do you have that code?
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Private Sub DataGridView1_Scroll(sender As Object, e As System.Windows.Forms.ScrollEventArgs) Handles DataGridView1.Scroll

End Sub
Most Valuable Expert 2012
Top Expert 2014
Commented:
> MsgBox("Scrolling error " & ex.Message)

Is it above statement that comes up? Comment that out.
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial