How to synchronize two or more grids while scrolling in WinForms GridControl?
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: