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

        }

posted @ 2009-09-01 15:16  汉城  阅读(639)  评论(0编辑  收藏  举报