Using one scrollbar to control two DataGridViews

I am trying to control two DataGridViews, only visible vertical scrollbars of a DataGridView.

0
source share
2 answers
protected void grid1_Scroll(object sender, ScrollEventArgs e)
{
    grid2.VerticallScrollBar.Value = e.NewValue;
}
+5
source

In Form.Load ():

Grid1.Scroll += (s, ev) => Grid2.VerticalScrollBar.Value = Grid1.VerticalScrollBar.Value;

Edit: We cannot assign Grid2.VerticalScrollingOffset, as I originally proposed, since this is a ReadOnly property.

0
source

All Articles