![]() |
Windows Control: The Numeric Up-Down |
|
Description |
|
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 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.
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 using System;
using System.Drawing;
using System.Windows.Forms;
public class Exercise : System.Windows.Forms.Form
{
NumericUpDown nudCounter;
public Exercise()
{
InitializeComponent();
}
private void InitializeComponent()
{
nudCounter = new NumericUpDown();
nudCounter.Location = new Point(12, 12);
Controls.Add(nudCounter);
}
}
public class Program
{
static int Main()
{
System.Windows.Forms.Application.Run(new Exercise());
return 0;
}
}
This would produce: ![]() |
|
|
||
| Home | Copyright © 2007 FunctionX, Inc. | Next |
|
|
||