DataGridView滚动条同步滚动

用scroll事件
private   void   dataGridView1_Scroll(object   sender,   ScrollEventArgs   e)
{
  //水平滚动条滚动
             if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
             {
               //设置DataGridView1和DataGridView2的水平滚动条的像数数相同
               dataGridView1.HorizontalScrollingOffset   =   dataGridView2.HorizontalScrollingOffset; 

             }

}

你可能感兴趣的:(C#)