When setting VerticalScroll.Value in a Panel with AutoScroll set to true, the scroll position changes accordingly but the
I was trying to get it to work on a Form. I tried the PerformLayout(), I tried Application.DoEvents(), I tried assigning the VerticalScroll.Value twice, none of it worked. The only thing I got to work was to change a property of VerticalScroll to a different value, and then change it back:
protected override void OnVisibleChanged(EventArg e)
{
base.OnVisibleChanged(e);
if (this.Visible)
{
this.VerticalScroll.Maximum++;
this.VerticalScroll.Maximum--;
}
}
Note that it works just as well to change VerticalScroll.Value, but you have to actually modify its value, and making sure the change is in the range of Minimum to Maximum is a lot more complex than just increasing Maximum temporarily.