TrackBar

The TrackBar control resembles the ScrollBar because it provides a slider, analogous to the thumb of the scrollbar, for the user to position with the mouse or keyboard. The relative position of the slider is exposed as the Value of the control. Unlike the ScrollBar, there are no separate horizontal and vertical versions of the TrackBar control. Instead, an Orientation property can have the value of either Horizontal or Vertical. You can also change the background color using the BackColor property, unlike the ScrollBar control, although you still can't change the ForeColor or BackgroundImage properties or set the Text property.

A horizontal track bar is similar to a horizontal scrollbar in that the Value property increases as the slider is moved from left to right. In contrast, the vertical track bar is opposite the vertical scrollbar: the Value of a vertical scrollbar increases from top to bottom, but the value of a vertical track bar increases from bottom to top. This makes sense if you think about the primary use of the two controls: a scrollbar is usually used for positioning, but a track bar is generally used for setting a value.

Many of the TrackBar control's commonly used properties are listed in Table 13-13.

Table 13-13. TrackBar properties

Property

Value type

Description

AutoSize

Boolean

Read/write. If true (the default), the thickness of the control is sized automatically—the thickness (height or width for horizontal or vertical controls, respectively) is not ...

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.