Scrollbar does not update on changing the scroll value
Try calling .PerformLayout();
Thanks for the .PerformLayout()
tip!
It wasn't enough in my case, I am setting the VerticalScroll.Value within the form Form.Shown
event handler, and for some reason I had to add a DoEvents
instruction beforehand for the scrolling to work.
Here's my Shown
event handler:
Private Sub MyForm_Shown(sender As System.Object, e As System.EventArgs) Handles Me.Shown
System.Windows.Forms.Application.DoEvents()
ScrollPanel.VerticalScroll.Value = ScrollPanel.VerticalScroll.Maximum
ScrollPanel.PerformLayout()
End Sub
ScrollPanel control is of type System.Windows.Forms.Panel
.
Without the Application.DoEvents()
line, the vertical scrolling value setting was completely ignored.
I thought it might came in handy for someone else.