System.Windows.Forms.UpDownBase Class

Implements the basic functionality required by a spin box (also known as an up-down control).

See Also: UpDownBase Members

Syntax

[System.ComponentModel.Designer("System.Windows.Forms.Design.UpDownBaseDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
public abstract class UpDownBase : ContainerControl

Remarks

A spin box consists of a text box and a small vertical scroll bar, commonly referred to as a spin button control. The System.Windows.Forms.UpDownBase class links the two controls and allows the user to change the display in the text box by clicking the up or down buttons or by entering the appropriate type of value directly into the text box. Use the spin box in cases where you want to limit the list of values a user can select, similar to a list box or combo box. Depending upon the type of list you want to display, the advantage to using a spin box is that it allows you to quickly set a range of valid values, rather than adding items one at a time. Implementing a spin box requires less data validation than a text box, as you can limit the data type when you derive a class from System.Windows.Forms.UpDownBase. An example of this is the System.Windows.Forms.NumericUpDown class, which limits the values to the numeric type and uses a NumericUpDown.Minimum and NumericUpDown.Maximum property to validate the data.

To allow the user to use the arrow keys to change the contents of a spin box, set the UpDownBase.InterceptArrowKeys property to true. To restrict the user to values you specify, set the UpDownBase.ReadOnly property to true. To control the alignment of text in the spin box, set the UpDownBase.TextAlign property. To set the alignment of the up and down buttons in relation to the text box portion of the control, set the UpDownBase.UpDownAlign property to either LeftRightAlignment.Left or LeftRightAlignment.Right.

The UpDownBase.UpButton and UpDownBase.DownButton methods, when overridden, handle the clicking of the up or down buttons. When overridden, the UpDownBase.ValidateEditText and UpDownBase.UpdateEditText methods validate the value (either selected or entered) and update the text displayed in the spin box. If the value fails validation, use the UpDownBase.Select(int, int) method to select the text that is not valid. This allows the user to quickly correct the text by simply typing in a new value without having to manually select or delete the existing text.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0