I have 2 DataGridViews
. Assume that they have always the same amount of rows with the same height. Whenever I move the ScrollBar
on one of them (both with the MouseWheel
and the ScrollBar
), I'd like to move the other one simultaneously (I only want to do this on the vertical ScrollBars
). How can I achive this?
CodePudding user response:
What @Caius Jard is saying to you to do is:
First, create two DataGridView, then on the Scroll
event sync the FirstDisplayedScrollingRowIndex
.
dataGridView1.Scroll = DataGridView1OnScroll;
private void DataGridView1OnScroll(object sender, ScrollEventArgs scrollEventArgs) {
dataGridView2.FirstDisplayedScrollingRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
}
Observation
I tried to use WndProc
to sync two DataGrids, using this, but it did not work… Well, it worked with the mouse wheel, but not by dragging the scrollbar.