I'm having trouble scrolling some datagrids so they sync up...
I have two identical datagrids on a form, filled with eh same dataset. I want a user to be able to scroll on the datasets and the
other dataset then scrolls to the same place on the other dataset (bare with me). This is the code that I have so far...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(IssueDataset1)
For Each acontrol As Control In DataGrid1.Controls
If acontrol.GetType() Is GetType(VScrollBar) Then
AddHandler CType(acontrol, VScrollBar).Scroll, AddressOf vertChange
Exit For
End If
Next
End Sub
Private Sub vertChange(ByVal sender As Object, ByVal e As ScrollEventArgs)
Static Dim Value As Integer = 0
Dim hHScroll As IntPtr = FindWindowEx(DataGrid2.Handle, New IntPtr(0), "WindowsForms10.SCROLLBAR.app3", Nothing)
Dim hVScroll As IntPtr = FindWindowEx(DataGrid2.Handle, hHScroll, "WindowsForms10.SCROLLBAR.app3", Nothing)
If e.NewValue > Value Then
SendMessage(DataGrid2.Handle, MsgType.WM_VSCROLL, CType(MsgType.SB_PAGERIGHT, Integer), hVScroll.ToInt32)
Else
SendMessage(DataGrid2.Handle, MsgType.WM_VSCROLL, CType(MsgType.SB_PAGELEFT, Integer), hVScroll.ToInt32)
End If
Value = e.NewValue
End Sub
I can get the datagrids to move together, but they don't always end up on the same line as each other. Anyone have any code to fix
this?
Thanks a bunch!
Scott