sync Scrolling problem

onepieceking

Well-known member
Joined
Sep 20, 2006
Messages
64
Programming Experience
1-3
Hi,

I have 2 panels that are horizontal scrollable and in these 2 panels, they each contains a picturebox. The pictureboxes are auto-sized, meaning that they can be bigger than the panels.

What I want to do is when both panels display their scrollbars, I want to raise a scroll event, meaning when I scroll "panel 1", "panel 2" will auto-scroll itself to the position where I stop for "panel 1".

How do i do it? Thanks.
 
VB.NET:
Private Sub Panel1_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) _
Handles Panel1.Scroll
    If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
        Panel2.HorizontalScroll.Value = Panel1.HorizontalScroll.Value
    Else
        Panel2.VerticalScroll.Value = Panel1.VerticalScroll.Value
    End If
End Sub
 
Thanks John.

I also found another method

VB.NET:
panel1.autoscrollposition = new point(-panel2.autoscrollposition.X, _
   -panel2.autoscrollposition.Y)
 
Back
Top