The following example demonstrates how to scroll the second grid ( gridControl2 ) in sync with the first grid (gridControl1). If you want to sync the scrolling of the first grid when the second grid is scrolled, then you will also need to handle the FirstVisibleRowChanged and FirstVisibleColumnChanged events of the second grid.
Private Sub GridControl1_FirstVisibleRowChanged(ByVal sender As Object, ByVal e As System.EventArgs) GridControl2.FirstVisibleRow = gridControl2.DataRows( CType( GridControl1.FirstVisibleRow, _ Xceed.Grid.DataRow ).Index) End Sub
Private Sub GridControl1_FirstVisibleColumnChanged(ByVal sender As Object, _ ByVal e As System.EventArgs)
If Not GridControl1.FirstVisibleColumn Is Nothing And _ Not GridControl2.FirstVisibleColumn Is Nothing Then
GridControl2.FirstVisibleColumn = GridControl2.Columns( GridControl1.FirstVisibleColumn.Index ) End If End Sub
C#
Copy Code
gridControl1.FirstVisibleRowChanged += new EventHandler( this.gridControl1_FirstVisibleRowChanged );
gridControl1.FirstVisibleColumnChanged += new EventHandler( this.gridControl1_FirstVisibleColumnChanged );