WinForm最简单两GridView同步滚动 (C#)

一个最简单方法:) 不过大数据量时候闪啊闪。  

private   void  dataGridView1_Scroll( object  sender, ScrollEventArgs e)
{
       dataGridView2.FirstDisplayedScrollingRowIndex 
=  dataGridView1.FirstDisplayedScrollingRowIndex;
       dataGridView2.HorizontalScrollingOffset 
=  dataGridView1.HorizontalScrollingOffset;
 }

private   void  dataGridView2_Scroll( object  sender, ScrollEventArgs e)
{
       dataGridView1.FirstDisplayedScrollingRowIndex 
=  dataGridView2.FirstDisplayedScrollingRowIndex;
       dataGridView1.HorizontalScrollingOffset 
=  dataGridView2.HorizontalScrollingOffset;
}

你可能感兴趣的:(WinForm最简单两GridView同步滚动 (C#))