I have had some trouble changing the ScrollBar’s width in an application I’ve been asked to modify. Obviously, the first thing to do was to search for a Size property for the panel’s scroll bar. Just as expected, there wasn’t any. What could I do more? Surely Google (or Bing…) would have the answer!

But surprise! No good answer on the first 6 pages that Google showed up. So I started checking the Components toolbox again, and there it was: VScrollBar.

It is probably the best way to have a larger scroll bar in your application, since this component has a Size property. Linking the component to the form or panel you want to scroll is as easy as enabling the component’s Scroll event and writing down

panelName.VerticalScroll.Value = vScrollBar.Value;

Now, if you want to be 100% sure about how the scroll bar looks like, simply set the component’s Maximum property to the difference of the panel’s length (should I call it height), and the portion of the panel that is not showed (the one that should be scrolled for…).

In the end, I suggest you use a panel, for easier and safer usage of the vScrollBar.

Hope the post is clear enough. If not, don’t hesitate to ask your question in a comment.

Alex.

Leave a Reply

Post Navigation