This is for a windows form.
Panel has AutoScroll = True
I am adding panels dynamically to the main panel which end up exceeding the main panel display rectangle.
I found the answer to the problem I was having here: Answer
public class CustomPanel : System.Windows.Forms.Panel
{
protected override System.Drawing.Point ScrollToControl(System.Windows.Forms.Control activeControl)
{
// Returning the current location prevents the panel from
// scrolling to the active control when the panel loses and regains focus
return this.DisplayRectangle.Location;
}
}