WinForm最简单两GridView同步滚动
今天在园子里看到一个人问,如何让两个DataGridView保持同步滚动?
一个最简单方法:) 不过大数据量时候闪啊闪。
萝卜激动语录:没钱,就别玩大学这场游戏
一个最简单方法:) 不过大数据量时候闪啊闪。
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;
}
简单吧。{
dataGridView2.FirstDisplayedScrollingRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
dataGridView2.HorizontalScrollingOffset = dataGridView1.HorizontalScrollingOffset;
}
private void dataGridView2_Scroll(object sender, ScrollEventArgs e)
{
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex;
dataGridView1.HorizontalScrollingOffset = dataGridView2.HorizontalScrollingOffset;
}
萝卜激动语录:没钱,就别玩大学这场游戏