HScrollBar and VScrollBar Controls in VB.NET

Windows Forms ScrollBar controls are used to provide easy navigation through a long list of items or a large amount of information by scrolling either horizontally or vertically within an application or control.
  • 5033
Windows Forms ScrollBar controls are used to provide easy navigation through a long list of items or a large amount of information by scrolling either horizontally or vertically within an application or control. Scroll bars are a common element of the Windows interface.
 
Introduction
 
Windows Forms ScrollBar controls are used to provide easy navigation through a long list of items or a large amount of information by scrolling either horizontally or vertically within an application or control. Scroll bars are a common element of the Windows interface, so the ScrollBar control is often used with controls that do not derive from the ScrollableControl class. Similarly, many developers choose to incorporate the ScrollBar control when authoring their own user controls.

The HScrollBar (horizontal) and VScrollBar (vertical) controls operate independently from other controls and have their own set of events, properties, and methods. ScrollBar controls are not the same as the built-in scroll bars that are attached to text boxes, list boxes, combo boxes, or MDI forms (the TextBox control has a ScrollBars property to show or hide scroll bars that are attached to the control).

The ScrollBar controls use the Scroll event to monitor the movement of the scroll box (sometimes referred to as the thumb) along the scroll bar. Using the Scroll event provides access to the scroll bar value as it is being dragged.

Value Property

The Value property (which, by default, is 0) is an integer value corresponding to the position of the scroll box in the scroll bar. When the scroll box position is at the minimum value, it moves to the left-most position (for horizontal scroll bars) or the top position (for vertical scroll bars). When the scroll box is at the maximum value, the scroll box moves to the right-most or bottom position. Similarly, a value halfway between the bottom and top of the range places the scroll box in the middle of the scroll bar.

In addition to using mouse clicks to change the scroll-bar value, a user can also drag the scroll box to any point along the bar. The resulting value depends on the position of the scroll box, but it is always within the range of the Minimum to Maximum properties set by the user.

LargeChange and SmallChange Properties

When the user presses the PAGE UP or PAGE DOWN key or clicks in the scroll-bar track on either side of the scroll box, the Value property changes according to the value set in the LargeChangeproperty.

When the user presses one of the arrow keys or clicks one of the scroll-bar buttons, the Valueproperty changes according to the value set in the SmallChange property.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.