Question How to disable scrolling in a panel.

elie

New member
Joined
Dec 13, 2011
Messages
4
Programming Experience
1-3
A panel with enabled scrollbars has many buttons. If I push the tabulation key, focus navigates between buttons.
When a partially visible button has focus, the panel scrolls itself in order to completely show the button.
Is there a way to prevent that scrolling?
 
I haven't look very deep into this, but a simple way to achieve that is to write a class that inherits Panel and override ScrollToControl method, where you return AutoScrollPosition. That would make ScrollControlIntoView method useless for that Panel as well.
 
I haven't look very deep into this, but a simple way to achieve that is to write a class that inherits Panel and override ScrollToControl method, where you return AutoScrollPosition. That would make ScrollControlIntoView method useless for that Panel as well.

When I try to override the ScrollToControl Method, I get the following message:

"function ScrollToControl cannot be declared 'Overrides' because it does not override a function in a base class"

My code is the following:

Public Class MyPanel
Inherits Panel

Protected overrides function ScrollToControl (Byval activeControl as Control) As Point
return me.autoscrollPosition
End Function
 
In a Windows Forms application intellisense generates this code:
        Protected Overrides Function ScrollToControl(activeControl As System.Windows.Forms.Control) As System.Drawing.Point
            Return MyBase.ScrollToControl(activeControl)
        End Function

Where only the return value need to be changed, as I explained. The code is very similar to what you posted, still it indicates you have written that code manually, but in the forms app it is valid.
 
Back
Top