Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

How to sync two panel scrolls

5.00/5 (2 votes)
29 Nov 2010CPOL 17.8K  
C#
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;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)