ScrollBar

Scrollbars are everywhere in graphical user interfaces (GUIs). They can serve two different purposes: to shift the area of a graphical surface that is visible to the user (by far the most common usage) or to vary a parameter (similar to a TrackBar, described in the next section).

The ScrollableControl class, and all classes derived from it, can implement scrollbars for the purpose of moving around in a window or a region of a window by setting a single property:

AutoScroll = true

Controls that derive, directly or indirectly, from ScrollableControl include Form and Panel, so for many applications, this is all you need to know about scrollbars. With the AutoScroll property set to true, the form or panel will automatically include either horizontal and/or vertical scrollbars, as necessary, if the extent of controls drawn on the form or panel exceeds the visible client area. This is true at runtime either as a result of program action or user interaction.

In addition, most other controls that need scrollbars, such as the multiline TextBox, listbox, or combo box, already have them provided as part of the base functionality of those controls. As with the ScrollableControl objects, scrollbars appear as necessary with no effort required on the part of the developer.

However, automatically created scrollbars are mostly inaccessible to the developer. (There is some control of AutoScroll scrollbars through the use of the AutoScrollMargin, AutoScrollMinSize, and AutoScrollPosition properties, ...

Get Programming .NET Windows Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.