Scrollbar centralizing by itself

1

I have a form with height greater than the screen, with many buttons and checkboxes, The user uses the scroll bar to scroll down and see all the content of the form.

My problem is that every time the user tries to click a button or checkbox, the form tries to center this button in the middle of the user's screen by scrolling the scroll bar alone. This causes a lot of trouble, sometimes reading something and needs to activate a button, the form tries to centralize this button and scrolls the scroll bar, sometimes causes the user to even lose the click and have to click again.

I saw this as the default behavior of the Autoscroll = true property; But if I move to Autoscroll=false , the scroll bar disappears.

Is there a way to fix this? Visual studio 15, winforms

    
asked by anonymous 20.07.2017 / 19:20

1 answer

2

It is really the default behavior of scroll , triggering the ScrollToControl event by passing the control that was clicked.

You can overwrite this event in the container of your elements, returning DisplayRectangle.Location .

protected override Point ScrollToControl(System.Windows.Forms.Control activeControl)
{
    return DisplayRectangle.Location;
}
    
20.07.2017 / 19:33