I have searched the world wide web without a proper answer.
In my Windows Form application, i want to change the width of a scrollbar that belongs to a FlowLayoutPanel.
The Scrollbar is added "automatically" since the content of the Flow Layout Panel is larger the Form.
From what I've found on the web, it seems to be tricky.
Is there any solution to this?
Cheers!
No, there's no way to change the width of a scrollbar displayed on a single control (although there is a system-wide setting that will affect all scrollbars in all applications).
The ugly truth is that the lowly scrollbar control is far more complicated than it looks. Basically, the scrollbars on the FlowLayoutPanel
are drawn by Windows itself (rather than the .NET Framework) because of the WS_HSCROLL
and/or WS_VSCROLL
window styles that are set for the control behind the scenes. The FlowLayoutPanel
doesn't provide any facility to change or modify how these built-in scrollbars are drawn. Unlike other more advanced modifications in WinForms, there are no such messages we can send to the control's window procedure. And to make matters worse, the scrollbars are drawn in the non-client area of the FlowLayoutPanel
, which means we can't just override its Paint
event and handle drawing the scrollbars ourselves.
Unfortunately, if you really want to customize your scrollbars, you're going to have to hide the built-in scrollbars and roll your own. It's not quite as difficult as it sounds, though, if you're up for it. This article on CodeProject provides a good walk-through on creating your own skinnable scrollbar as a user control and use it as a replacement in the container control of your choice.
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