Home Forums WinForms controls Xceed Grid for WinForms How to synchronize the scrolling of two grids

Viewing 1 post (of 1 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #17824 |

    You can synchronize the scrolling of two grid’s using the FirstVisibleRowChanged and FirstVisibleColumnChanged events.

    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.


    AddHandler GridControl1.FirstVisibleRowChanged, AddressOf Me.GridControl1_FirstVisibleRowChanged
    AddHandler GridControl1.FirstVisibleColumnChanged, AddressOf Me.GridControl1_FirstVisibleColumnChanged

    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


    gridControl1.FirstVisibleRowChanged += new EventHandler( this.gridControl1_FirstVisibleRowChanged );
    gridControl1.FirstVisibleColumnChanged += new EventHandler( this.gridControl1_FirstVisibleColumnChanged );

    private void gridControl1_FirstVisibleRowChanged(object sender, System.EventArgs e)
      gridControl2.FirstVisibleRow = gridControl2.DataRows[ ( ( Xceed.Grid.DataRow )ridControl1.FirstVisibleRow ).Index ];

    private void gridControl1_FirstVisibleColumnChanged(object sender, System.EventArgs e)
      if( gridControl1.FirstVisibleColumn != null && gridControl2.FirstVisibleColumn != null )
        gridControl2.FirstVisibleColumn = gridControl2.Columns[ gridControl1.FirstVisibleColumn.Index ];               

    Imported from legacy forums. Posted by Xceed admin (had 2104 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.