![]() |
Windows Control: The Domain Up-Down |
|
Description |
|
A spin button, also called an up-down control, is usually made to display a numeric value that can then be increased or decreased when the user clicks one of the buttons of the controls. In a Microsoft Windows typical application, if you wanted to deal with values other than numbers, there was some gymnastic code to write. Fortunately, the .NET Framework provides a special spin button that can hold and display values other numbers. |
|
The .NET Framework's domain up-down control is a text-based object created from a class named DomainUpDown. Like NumericUpDown, the DomainUpDown class is derived from the UpDownBase class where it gets its primary functionality from.
At design time, to get a domain up-down control, from the Toolbox, you can click the DomainUpDown button and click the form. To programmatically create a domain up-down control, declare a variable of type DomainUpDown, initialize it and add it to the Controls property of the container that will hold it. Here is an example: using System;
using System.Drawing;
using System.Windows.Forms;
public class Exercise : System.Windows.Forms.Form
{
DomainUpDown spnNames;
public Exercise()
{
InitializeComponent();
}
private void InitializeComponent()
{
spnNames = new DomainUpDown();
Controls.Add(spnNames);
}
}
public class Program
{
static int Main()
{
System.Windows.Forms.Application.Run(new Exercise());
return 0;
}
}
This would produce:
|
|
|
||
| Home | Copyright © 2007 FunctionX, Inc. | Next |
|
|
||