using System;
using System.Drawing;
using System.Windows.Forms;
public class NumericUpDowns : Form
{
NumericUpDown nupdwn;
public NumericUpDowns()
{
Size = new Size(480,580);
nupdwn = new NumericUpDown();
nupdwn.Parent = this;
nupdwn.Location = new Point(50, 50);
nupdwn.Size = new Size(60,20);
nupdwn.Value = 1;
nupdwn.Minimum = -10;
nupdwn.Maximum = 10;
nupdwn.Increment = .25m; // decimal
nupdwn.DecimalPlaces = 2;
nupdwn.ReadOnly = true;
nupdwn.TextAlign = HorizontalAlignment.Right;
nupdwn.ValueChanged += new EventHandler(nupdwn_OnValueChanged);
}
private void nupdwn_OnValueChanged(object sender, EventArgs e)
{
Console.WriteLine(nupdwn.Value);
}
static void Main()
{
Application.Run(new NumericUpDowns());
}
}
|