65.9K
CodeProject is changing. Read more.
Home

How to sync two panel scrolls

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Nov 29, 2010

CPOL
viewsIcon

17915

private void splitContainer1_Panel1_Scroll(object sender, ScrollEventArgs e)
{
    if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
        splitContainer1.Panel2.HorizontalScroll.Value = e.NewValue;
    else if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
        splitContainer1.Panel2.VerticalScroll.Value = e.NewValue;
}
private void splitContainer1_Panel2_Scroll(object sender, ScrollEventArgs e)
{
    if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
        splitContainer1.Panel1.HorizontalScroll.Value = e.NewValue;
    else if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
        splitContainer1.Panel1.VerticalScroll.Value = e.NewValue;
}