We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to synchronize two or more grids while scrolling in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019
Tags: scrolling

Synchronize grid

To synchronize grids, you must handle the TopRowChanged and LeftColChanged events and assign the other grid's TopRowIndex and LeftColIndex to the current grid.

C#

//Left column index of the grid1 is assigned to the left column index of the grid2 and grid3
void gridControl1_LeftColChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl2.LeftColIndex = this.gridControl1.LeftColIndex;
   this.gridControl3.LeftColIndex = this.gridControl1.LeftColIndex;
}
//Top row index of the grid1 is assigned to the Top row index of the grid2 and grid3
void gridControl1_TopRowChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl2.TopRowIndex = this.gridControl1.TopRowIndex;
   this.gridControl3.TopRowIndex = this.gridControl1.TopRowIndex;
}
//Left column index of the grid2 is assigned to the left column index of the grid1
void gridControl2_LeftColChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl1.LeftColIndex = this.gridControl2.LeftColIndex;
}
//Top row index of the grid2 is assigned to the top row index of the grid1
void gridControl2_TopRowChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl1.TopRowIndex = this.gridControl2.TopRowIndex;
}
//Left column index of the grid3 is assigned to the left column index of the grid1
void gridControl3_LeftColChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl1.LeftColIndex = this.gridControl3.LeftColIndex;
}
//Top row index of the grid3 is assigned to the top row index of the grid1
void gridControl3_TopRowChanged(object sender, Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs e)
{
   this.gridControl1.TopRowIndex = this.gridControl3.TopRowIndex;
}

VB

'Left column index of the grid1 is assigned to the left column index of the grid2 and grid3
Private Sub gridControl1_LeftColChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl2.LeftColIndex = Me.gridControl1.LeftColIndex
    Me.gridControl3.LeftColIndex = Me.gridControl1.LeftColIndex
End Sub
'Top row index of the grid1 is assigned to the Top row index of the grid2 and grid3
Private Sub gridControl1_TopRowChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl2.TopRowIndex = Me.gridControl1.TopRowIndex
    Me.gridControl3.TopRowIndex = Me.gridControl1.TopRowIndex
End Sub
'Left column index of the grid2 is assigned to the left column index of the grid1
Private Sub gridControl2_LeftColChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl1.LeftColIndex = Me.gridControl2.LeftColIndex
End Sub
'Top row index of the grid2 is assigned to the top row index of the grid1
Private Sub gridControl2_TopRowChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl1.TopRowIndex = Me.gridControl2.TopRowIndex
End Sub
'Left column index of the grid3 is assigned to the left column index of the grid1
Private Sub gridControl3_LeftColChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl1.LeftColIndex = Me.gridControl3.LeftColIndex
End Sub
'Top row index of the grid3 is assigned to the top row index of the grid1
Private Sub gridControl3_TopRowChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColIndexChangedEventArgs)
    Me.gridControl1.TopRowIndex = Me.gridControl3.TopRowIndex
End Sub

 

Samples:

C#: Synchronizing the_grids

VB: Synchronizing the_grids

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon