horizontal scrollbar 2 datagrids simultaneous

Droomgans

Member
Joined
Aug 29, 2007
Messages
8
Programming Experience
Beginner
Hi everybody

I have 2 datagrids on my form, and I want to 'synchronize' the scrolling of the horizontal scrollbars

so when the user scrolls the first datagrid, the second datagrid will also
scroll along :)

but how can I do this? anyone any idea?
thanks in advance

grtz
 
This handles both:
VB.NET:
Private Sub DataGridViews_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) _
Handles DataGridView1.Scroll, DataGridView2.Scroll
    If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
        If sender Is DataGridView1 Then
            Me.DataGridView2.HorizontalScrollingOffset = Me.DataGridView1.HorizontalScrollingOffset
        Else
            Me.DataGridView1.HorizontalScrollingOffset = Me.DataGridView2.HorizontalScrollingOffset
        End If
    End If
End Sub
 
Back
Top