UpDown Controls

An up-down control consists of a text box plus a small vertical scrollbar, which is used to change the value being displayed.

.NET gives you two up-down classes, DomainUpDown and NumericUpDown, both of which derive from the UpDownBase class.

The NumericUpDown class provides an up-down control that displays a numeric value, which is incremented and decremented using scrollbar buttons. Table 10.18 shows the properties of the NumericUpDown class. Value can be used to get and set the value, and it is validated against the Maximum and Minimum. If validation fails, an ArgumentException will be thrown. A DomainUpDown control displays strings from an Object collection by clicking the up and down buttons. Table 10.19 shows the properties of this class. ltems represents the collection of strings held by the control, and you can use the normal collection Add(), Remove(), and Clear() methods to maintain the list.

Table 10.18: Iprtsilitaifli is

Property

Description

DecimalPlaces

The number of decimal places to display. The default is zero.

Hexadecimal

True if values are displayed in hex. The default is false.

Increment

The increment value to use when the up or down button is clicked. The default is 1.

Maximum

The maximum value that can be displayed. The default is 100.

Table 10.18: Iprtitaifli class

Property

Description

Minimum

The minimum value that can be displayed. The default is 0.

RealOnly

True if the control is read-only, in which case the user cannot enter text into the textbox.

ThousanlsSeparator

True if a thousands separator is to be displayed. The default is false.

Value

The value being displayed in the control.

Table 10.19: Iprtikifli Is

Property

Description

Items

The collection of items.

Selectellnlex

Gets or sets the selected item by index.

Selectelltem

Gets or sets the selected item by reference.

Sortel

If true, the list items are maintained in sorted order.

Wrap

If true, the list wraps when the beginning or end is reached.

0 0

Post a comment