dataGridView 滚动条 同步

private void dataGridView1_Scroll(object sender, ScrollEventArgs e)
        {

            if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
            {
                dataGridView1.HorizontalScrollingOffset = e.NewValue;
            }
            else
            {
                dataGridView1.FirstDisplayedScrollingRowIndex = e.NewValue;// / dataGridView1.RowTemplate.Height;
                //Application.DoEvents();
            }

        }

        private void dataGridView2_Scroll(object sender, ScrollEventArgs e)
        {
            dataGridView1_Scroll(sender, e);

        }

原文地址:https://www.cnblogs.com/ok519/p/1558087.html