Auto-scrolling issue on mousedown

I have a custom control inside the autoscroll panel. When the user control goes beyond the width of the panel, scroll bars appear. When you scroll any distance and mousedown on the control, the scrollbar returns to 0. Does anyone know why this could be? I'm sure I'm not trying to change the scroll value anywhere ...

thanks

EDIT: This only happens once when you click on it every time it works as expected

EDIT 2: This also happens when you bring a new window up and then return to a C # window

+4
source share
1 answer

If you have a control (e.g. TextBox ) that is much wider than the container, and you scroll to the end, then click on the control, you will scroll back to the Location control.

The selected control gains focus, and scrolling occurs automatically, this is the standard behavior of winforms.

If you want to undo this, you will need to intercept the SetAutoScrollPosition container ( ScrollableControl ) or use another mechanism to return to its original position.

If the control already has focus and then scrolls, pressing it again does not change the container's AutoScrollPosition .

+1
source

Source: https://habr.com/ru/post/1339543/


All Articles