C#DataGridView两个数据表同步滚动

发布时间 2023-07-17 16:35:54作者: 青丝·旅人
        private void SumTable_Scroll(object sender, ScrollEventArgs e)//滚动同步
        {
            CycleTable.FirstDisplayedScrollingRowIndex = SumTable.FirstDisplayedScrollingRowIndex;//行滚动同步
            //CycleTable.FirstDisplayedScrollingColumnIndex = SumTable.FirstDisplayedScrollingColumnIndex;//列滚动同步
        }
        private void CycleTable_Scroll(object sender, ScrollEventArgs e)//滚动同步
        {
            SumTable.FirstDisplayedScrollingRowIndex = CycleTable.FirstDisplayedScrollingRowIndex;
            //SumTable.FirstDisplayedScrollingColumnIndex = CycleTable.FirstDisplayedScrollingColumnIndex;//列滚动同步
        }

CycleTable为表2,
SumTable为表1
两个表都添加Scroll滚动事件