Home > DeveloperSection > Articles > NumericUpDown Control in C#.Net

NumericUpDown Control in C#.Net


C# C# 
Ratings:
0 Comment(s)
 15744  View(s)
Rate this:

NumericUpDown Control in C#.Net

A NumericUpDown control is provide a way to select a number that falls between a minimum and a maximum value. The numeric value can be incremented or decremented by clicking the up or down buttons of the control. The user can also enter a value.

How to use NumericUpDown Control

Drag and drop NumericUpDown Control and a textbox from toolbox on window Form.

NumericUpDown Control in C#.Net

Code:

Write code on ValueChanged event of NumericUpDown control.

NumericUpDown Control in C#.Net

Double click on ValueChanged event.

private void numericUpDown1_ValueChanged(object sender, EventArgs e)

{

            //selected value will show in TextBox

            textBox1.Text = numericUpDown1.Value.ToString();

}

Run the project

NumericUpDown Control in C#.Net

When you will run the project the initial value of NumericUpDown will be 0. Now when you change the value of NumericUpDown then changed value will also show in textbox.

NumericUpDown Control in C#.Net

NumericUpDown Control Properties

DecimalPlaces:  Set the number of decimal places to display in NumericUpDown Control.

UpDownAlign:  Set positions the arrow buttons on the left or the right side of the NumericUpDown. Default value is Right.

Increment:  Gets or sets the value to increment or decrement the NumericUpDown.

 

Example:

private void frmNumericUpDown_Load(object sender, EventArgs e)

{

        //Increment the NumericUpDown value

        numericUpDown1.Increment = 5;

}

NumericUpDown value will be inrement 5 at each up button click.

NumericUpDown Control in C#.Net

Hexadecimal:   Hexadecimal property used to show value in Hexadecimal format in NumericUpDown. Default value is false.

Example:

private void frmNumericUpDown_Load(object sender, EventArgs e)

{

            // allow to show value in Hexadecimal format

              numericUpDown1.Hexadecimal = true;

}

NumericUpDown Control in C#.Net


Don't want to miss updates? Please click the below button!

Follow MindStick