How to block form scrolling when I'm dragging a control?

0

I have a form where I design the supply network of a company. For this, I need to allow the user to move the controls that are in the form.

This is working.

However, when the user moves the control beyond the current position of the form, the form increases in size and rolls (right, left, up or down), and the control being dragged is pushed further, which makes the form scroll more, and so on.

The form continues scrolling, perhaps increasing in size, until the user releases the mouse button.

To fix this, I need to prevent scrolling of the form when moving the control. How can I do this?

    
asked by anonymous 25.09.2015 / 16:20

1 answer

0

By replying to Loathing in SOen:

You can prevent the form from rolling by using this code, overriding the ScrollToControl method:

protected override Point ScrollToControl(Control activeControl) {
    Point pt = this.AutoScrollPosition;
    return pt;
}
    
25.09.2015 / 16:20