NumericUpDown: set value, Minimum, Maximum, Increment, Decimal places, Readonly, TextAlign : NumericUpDown « GUI Windows Forms « C# / CSharp Tutorial






NumericUpDown: set value, Minimum, Maximum, Increment, Decimal places, Readonly, TextAlign
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());
  }
}








23.12.NumericUpDown
23.12.1.NumericUpDown: set value, Minimum, Maximum, Increment, Decimal places, Readonly, TextAlignNumericUpDown: set value, Minimum, Maximum, Increment, Decimal places, Readonly, TextAlign
23.12.2.NumericUpDown: value changed eventNumericUpDown: value changed event
23.12.3.Get value from NumericUpDownGet value from NumericUpDown
23.12.4.NumericUpDown Value changed event handlerNumericUpDown Value changed event handler
23.12.5.NumericUpDown validating eventNumericUpDown validating event
23.12.6.NumericUpDown validated eventNumericUpDown validated event