I'm trying to use VScrollBar class instead of standard scrollbar. I want to do this because I want to change something in the dimension and color of the scrollbar.
I'm trying to set Minimum, Maximum, SmallChange and LargeChange of my scrollbar control but I can't find a way to set correctly these values.
I did in this way:
vScrollBar.Minimum = 0;
vScrollBar.Maximum = this.pnlContainer.DisplayRectangle.Height;
vScrollBar.LargeChange = vScrollBar.Maximum /
vScrollBar.Height + this.pnlContainer.Height;
vScrollBar.SmallChange = 15;
But this.pnlContainer.DisplayRectangle.Height is a good value only if I set AutoScroll=true in the panel but in this way it shows his scrollbar.
I'm getting crazy.
Thank you for any help.
UPDATE
I need to use FlowLayoutPanel and not a generic Panel. Furthermore the Parent of my VScrollBar isn't my FlowLayoutPanel (this is something that now I can't change)
You can always create a custom control that inherits from Panel. This custom control will include your custom VScrollBar. In the custom control, override the AutoScroll property to ensure that it toggles the visibility of the standard scrollbar and your custom VScrollBar as needed.
Here's an example of how you can create such a custom panel control:
With this custom panel control, you can use it in your form like a standard Panel, and it will show your custom VScrollBar when AutoScroll is set to true. The standard scrollbar will be hidden. You can then add child controls to this custom panel and customize its appearance and behavior in the way you want.