Click here to Skip to main content
15,890,336 members
Articles / Programming Languages / C#
Tip/Trick

How to sync two panel scrolls

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
29 Nov 2010CPOL 17.6K   2   2
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)



Comments and Discussions

 
GeneralMy vote of 5 Pin
Member 156862175-Apr-24 3:16
Member 156862175-Apr-24 3:16 
QuestionThis does not work Pin
joseph_korn8-Dec-15 12:30
joseph_korn8-Dec-15 12:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.