Problem with AutoScroll

Problem with AutoScroll

Anonymous
Not applicable
1,590 Views
2 Replies
Message 1 of 3

Problem with AutoScroll

Anonymous
Not applicable
I have a form that I have constructed and placed into a Palette window. This form starts out as a "UserControl". Inside of that is a TableLayoutPanel. Inside of that is a FlowLayoutPanel. Inside of that are 6 DataGridViews. The FlowLayoutPanel has AutoScroll turned on. Each datagrid also has AutoScroll turned on (both directions). The intent is that I can show or hide the data grid views depending on the data rows that I want to show. When I show a list that is longer than the palette window, the autoscroll bars turn on as expected.



Now the problem: When I scroll down on the list of a long DataGridView using the scroll bar from the FlowLayoutPanel, the rows display. When I click on one of the lower rows, the scrollbar for the FlowLayoutPanel scrolls back to the top. This problem effectively selects ALL the rows from the one i click on back up to the last one visible from a top most scroll.



Example: There are 21 rows in existance. 18 are visible. I scroll down to see row 21, then I select it. From a single distinct click, i get rows 21 through 18 all selected, and the scroll bar is back on top.



The vertical scrollbars for the data grid views never came on, because they are docked to the Flow Layout Panel who is docked to the TableLayoutPanel who is docked to the UserControl. All the controls are set to AutoSize True (grow and shrink).



How do i get this automatic scrolling to the top issue to stop?



Thanks,



jvj
0 Likes
1,591 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
To clarify, the AutoScroll is taking place by the FlowLayoutPanel to scroll to the top of the DataGridView of the row I selected. This issue was mentioned before, but a solution was never discussed. The DataGridView is taking the focus, then the Scroll bar is scrolling up, then then DataGridView Row and Cell I selected gets its focus (off screen) but my mouse clicked in a certain area, so the DataGridView selects multiple rows. Perhaps I can control the AutoScroll of the FlowLayoutPanel, and direct it to center the row I selected (or not to activate unless told to do so)...
0 Likes
Message 3 of 3

Anonymous
Not applicable
I have solved my problem with help from other vb.net forums...



I created a custom panel that inerits windows.forms.panel and overrides one function:




Public Class NoAutoScrollPanel



Inherits Windows.Forms.Panel



Public Sub New()



MyBase.New()



End Sub



Protected Overrides Function ScrollToControl(ByVal activeControl As System.Windows.Forms.Control) As System.Drawing.Point



Return Me.AutoScrollPosition



End Function



End Class



Then placed all my data grids (5 stacked top to bottom docked to top only of the panel) into this no auto scroll panel instead of the FlowLayoutPanel. The bottom line is this panel activates the scroll bar when needed, and scrolls as desired, but does not AutoScroll by clicking on any control at any level.



Later,



jvj

0 Likes