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);

        }

你可能感兴趣的:(datagridview)