Synchronize datagrid Scroll vertical


  • Hi,

    I am having two datagrid side by side. I want to vertically scroll both datagrid at a time ie synchronize both scroll bar movement vertically.

     kindly give code sample to do so.
    Thursday, January 21, 2010 5:03 AM


  • Hi,

    Do you mean datagridview control?
    Please try the code below:

            private void dataGridView1_Scroll(object sender, ScrollEventArgs e)


                this.dataGridView2.FirstDisplayedScrollingRowIndex = this.dataGridView1.FirstDisplayedScrollingRowIndex;

                this.dataGridView2.HorizontalScrollingOffset = this.dataGridView1.HorizontalScrollingOffset;



            private void dataGridView2_Scroll(object sender, ScrollEventArgs e)


                this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView2.FirstDisplayedScrollingRowIndex;

                this.dataGridView1.HorizontalScrollingOffset = this.dataGridView2.HorizontalScrollingOffset;


    For more info , please take a look at the thread:


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Benita Blas Monday, January 25, 2010 11:44 AM
    Monday, January 25, 2010 8:47 AM