Open In App

C# | NumericUpDown Class

In Windows Forms, NumericUpDown control is used to provide a Windows spin box or an up-down control which displays the numeric values. Or in other words, NumericUpDown control provides an interface which moves using up and down arrow and holds some pre-defined numeric value. The NumericUpDown class is used to represent the windows numeric up-down box and also provide different types of properties, methods, and events. It is defined under System.Windows.Forms namespace. In C# you can create a NumericUpDown in the windows form by using two different ways:

1. Design-Time: It is the easiest way to create a NumericUpDown as shown in the following steps:



2. Run-Time: It is a little bit trickier than the above method. In this method, you can create a NumericUpDown control programmatically with the help of syntax provided by the NumericUpDown class. The following steps show how to set the create NumericUpDown dynamically:

Constructor

Constructor Description
NumericUpDown() This Constructors is used to initialize a new instance of the NumericUpDown class.

Properties

Property Description
AutoSize This property is used to get or set a value that indicates whether the control resizes based on its contents.
BackColor This property is used to get or set the background color for the control.
BorderStyle This property indicates the border style for the control.
Font This property is used to get or set the font of the text displayed by the control.
ForeColor This property is used to get or set the foreground color of the control.
Height This property is used to get or set the height of the control.
Location This property is used to get or set the coordinates of the upper-left corner of the NumericUpDown control relative to the upper-left corner of its form.
Name This property is used to get or set the name of the control.
TabStop This property is used to get or set a value that shows whether the user can press the TAB key to provide the focus to the NumericUpDown.
Size This property is used to get or set the height and width of the control.
Text This property is used to get or set the text to be displayed in the NumericUpDown control.
TextAlign This property is used to get or set the alignment of the text in the spin box (also known as an up-down control).
Visible This property is used to get or set a value indicating whether the control and all its child controls are displayed.
Width This property is used to get or set the width of the control.
UpDownAlign This property is used to get or set the alignment of the up and down buttons on the spin box (also known as an up-down control).
ThousandsSeparator This property is used to get or set a value indicating whether a thousands separator is displayed in the spin box (also known as an up-down control) when appropriate.
Hexadecimal This property is used to get or set a value indicating whether the spin box (also known as an up-down control) should display the value it contains in hexadecimal format.
Increment This property is used to get or set the value to increment or decrement the spin box (also known as an up-down control) when the up or down buttons are clicked.

Article Tags :
C#