When setting VerticalScroll.Value
in a Panel
with AutoScroll
set to true
, the scroll position changes accordingly but the position of the thumb does not. Do I need to update the scrollbar somehow (Invalidate(true)
on the panel does not work)? Any ideas?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With