Home > Articles

This chapter is from the book

Using the TrackBar Control

The TrackBar control is a special slider control that allows the user to select a numeric value by changing the position of the slider. The TrackBar is controlled mainly by three properties: Minimum, Maximum, and Value. Given our earlier discussions, these values are self-explanatory.

The TrackBar exposes a few additional properties that control the appearance and behavior of the TrackBar. The Orientation property determines whether the TrackBar is oriented on the horizontal or vertical axis. The TickFrequency property defines the distance between the tick marks along the slider. By default the TickFrequency is set to one. The SmallChange and LargeChange properties define increment values. SmallChange defines how much the Value is incremented when the user presses one of the Pocket PC navigation pad arrow keys. The LargeChange property defines how much the Value is incremented when the user clicks the TrackBar on either side of the slider.

When the TrackBar controls value is changed, a ValueChanged event is fired. You can handle this event to update whatever properties that are linked to the TrackBar. Figure 3.14 shows two TrackBars that are identical except that one is oriented vertically and the other horizontally. The horizontal TrackBar controls the vertical, meaning that the value of the vertical TrackBar control will change to match the value of the horizontal TrackBar control.

Figure 3.14Figure 3.14 An application that showcases the TrackBar control running on the Pocket PC 2002 emulator.

  • + Share This
  • 🔖 Save To Your Account