I would like to synchronize the scroll event of two DataGridView controls, so that when I horizontally scroll the first DataGridView , the second DataGridView also should be scrolled at the same time. Below is the code for the first DataGridView;
Private Sub BasicChildInfoGridView_Scroll(sender As Object, e As ScrollEventArgs) Handles BasicChildInfoGridView.Scroll
If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then Exit Sub
If Me.DataGridViewSummary.Rows.Count > 0 And Me.BasicChildInfoGridView.Rows.Count > 0 Then
Me.DataGridViewSummary.HorizontalScrollingOffset = e.NewValue
End If
End Sub
However, its indicating that “Property ‘HorizontalScrollingOffset ‘ is Read-Only”. How can I access it or what workaround can I apply?
If I use another method below;
Private Sub scrl_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim row As Integer = DataGridViewSummary.FirstDisplayedCell.RowIndex
Dim col As Integer = DataGridViewSummary.FirstDisplayedCell.ColumnIndex
BasicChildInfoGridView.FirstDisplayedCell = BasicChildInfoGridView(col, row)
End Sub
It also says that “Property ‘FirstDisplayedCell ‘ is Read-Only”. How can I overcome this challenge?
Thank you
Adrian
It’s difficult because you have to sync column resizing, column movements, appearance/disappearance of scrollbars, the horizontal scrollbar controls both grid, etc. We have an undocumented and unsupported internal js method called “bindToGrid”. See attached.
Please login first to submit.