DataGridView Scrolling
-
I have 2 DataGridView and I need them to scroll together. The first DataGridView has Scrollbars set to none and the second DataGridView is only displaying the Vertical scrollbar. I need the Sync. the second DataGridView's vertical scrollbar to move the first DataGridView's vertical position.
Private Sub _Scrolling(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Dim g As DataGridView = CType(Me.MainTabControl.Controls.Find("Employee_times", True)(0), DataGridView) ' need help tranfering the event to the first DataGridView End Sub
Thanks. -
I have 2 DataGridView and I need them to scroll together. The first DataGridView has Scrollbars set to none and the second DataGridView is only displaying the Vertical scrollbar. I need the Sync. the second DataGridView's vertical scrollbar to move the first DataGridView's vertical position.
Private Sub _Scrolling(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Dim g As DataGridView = CType(Me.MainTabControl.Controls.Find("Employee_times", True)(0), DataGridView) ' need help tranfering the event to the first DataGridView End Sub
Thanks.Well, there's an easy way and a hard way. We'll try the easy way first: The easy way is to put both DGV's in a Panel control and turn scrolling on in the panel. Don't turn on scrolling in the DGV's and don't worry about how big they DGV get. Just let them grow as far as they want in the vertical direction. The panel will then take care of the scrolling for you.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Well, there's an easy way and a hard way. We'll try the easy way first: The easy way is to put both DGV's in a Panel control and turn scrolling on in the panel. Don't turn on scrolling in the DGV's and don't worry about how big they DGV get. Just let them grow as far as they want in the vertical direction. The panel will then take care of the scrolling for you.
Dave Kreskowiak Microsoft MVP - Visual Basic
How simple was that. LOL I ended up with a work around using the..
gTime.SetBounds(0, (-gEmployee.VerticalScrollingOffset) + 11, gTime.Size.Width, gTime.Size.Height)
Thanks for the help. I've been wanting to contribute to the site with an article of some sort. So, I'm thinking of using parts of my current project with the multiple datagridviews and runtime creation of them and linking. As my first attempt at an article on the site. Thanks again.