Windows Control: The Numeric Up-Down



A spin button, also called a spin box, also called an up/down control, is a Windows control equipped with two opposite arrow buttons The UpDown Control. The user clicks one of the arrow buttons at one time to increase or decrease the current value of the control. The value held by the control is also called its position. 

The values of an up/down control range from a minimum to a maximum. When the up arrow button is clicked, the value of the control increases. If the user clicks and holds the mouse on the up pointing arrow button, the value of the control keeps increasing until it reaches its maximum and then stops. The opposite behavior applies when the user clicks or holds the mouse on the down-pointing arrow button.

Creating an Up-Down Control

The .NET Framework provides two types of spin buttons. The immediate parent of the up/down control is the UpDownBase class.  This class provides the characteristics and behaviors common to both types of up/down controls.

As it name implies, the numeric up-down control is made to display numeric values. To use it, from the Common Controls section of the Toolbox, you can click the NumericUpDown button NumericUpDown and click the form or the container that will host it. This control is based on the NumericUpDown class that you can use to dynamically create the control. Here is an example:

using System;
using System.Drawing;
using System.Windows.Forms;

public class Exercise : System.Windows.Forms.Form
    NumericUpDown nudCounter;

    public Exercise()

    private void InitializeComponent()
        nudCounter = new NumericUpDown();
        nudCounter.Location = new Point(12, 12);


public class Program
    static int Main()
        System.Windows.Forms.Application.Run(new Exercise());
        return 0;

This would produce:

Numeric Up-Down

Home Copyright © 2007 FunctionX, Inc. Next