Up-Down Controls

Up-down controls consist of an edit box with an associated set of up and down arrows. The user can cycle through a range of values in the edit box by clicking on the arrows, or, if the ReadOnly property is not set to true, you can enter values in the edit box directly.

Tip

Up-down controls used to be known in other languages as spin controls or spinners.

Most up-down control functionality comes from the UpDownBase class. This is an abstract/MustInherit class; it is not instantiated directly. The .NET Framework provides two classes derived from UpDownBase: NumericUpDown and DomainUpDown. The NumericUpDown control displays numeric values in the edit box, and the DomainUpDown control displays string values representing members of a collection of objects.

In addition to the properties inherited from Control and other base classes, such as ScrollableControl, UpDownBase has other properties, the most commonly used of which are listed in Table 13-16.

Table 13-16. UpDownBase properties

Property

Value type

Description

BorderStyle

BorderStyle

Read/write. Valid values are members of the BorderStyle enumeration, listed in Table 13-9.

InterceptArrowKeys

Boolean

Read/write. If true (the default), user can use up and down arrow keys to select values when the control has focus.

PreferredHeight

Integer

Read-only. Height of control in pixels, based on PreferredHeight property of the text box portion of the control, adjusted for border style.

ReadOnly

Boolean

Read/write. ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.