Synchronize datagrid Scroll vertical
-
Thursday, January 21, 2010 5:03 AMHi,
I am having two datagrid side by side. I want to vertically scroll both datagrid at a time ie synchronize both scroll bar movement vertically.
kindly give code sample to do so.- Edited by Benita Blas Friday, June 11, 2010 6:48 AM
- Edited by Benita Blas Friday, June 11, 2010 6:48 AM
All Replies
-
Monday, January 25, 2010 8:47 AMModerator
Hi,
Do you mean datagridview control?
Please try the code below:
private void dataGridView1_Scroll(object sender, ScrollEventArgs e)
{
this.dataGridView2.FirstDisplayedScrollingRowIndex = this.dataGridView1.FirstDisplayedScrollingRowIndex;
this.dataGridView2.HorizontalScrollingOffset = this.dataGridView1.HorizontalScrollingOffset;
}
private void dataGridView2_Scroll(object sender, ScrollEventArgs e)
{
this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView2.FirstDisplayedScrollingRowIndex;
this.dataGridView1.HorizontalScrollingOffset = this.dataGridView2.HorizontalScrollingOffset;
}
For more info , please take a look at the thread:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/ef832fa4-b2bd-4d38-8bd2-2dae37557554/
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer by Benita Blas Monday, January 25, 2010 11:44 AM

