How to Sync horizontal scroll event of two DataGridViews ["Property 'HorizontalScrollingOffset ' is Read-Only"]

Answered
0
0

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

 

 

  • You must to post comments
Best Answer
0
0

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.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.