NumericUpDown.DecimalPlaces : NumericUpDown « System.Windows.Forms « C# / C Sharp by API






NumericUpDown.DecimalPlaces

 


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());
  }
}

   
  








Related examples in the same category

1.NumericUpDown.Increment
2.NumericUpDown.Maximum
3.NumericUpDown.Minimum
4.NumericUpDown.ReadOnly
5.NumericUpDown.TextAlign
6.NumericUpDown.ThousandsSeparator
7.NumericUpDown.UpDownAlign
8.NumericUpDown.Value
9.NumericUpDown.Validated
10.NumericUpDown.Validating
11.NumericUpDown.ValueChanged