Csharp/C Sharp by API/System.Windows.Forms/NumericUpDown — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:10, 26 мая 2010

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


NumericUpDown.Increment

 

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


NumericUpDown.Maximum

  

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
   private System.Windows.Forms.NumericUpDown yearUpDown;
   private System.Windows.Forms.Button calculateButton;
   public Form1() {
      InitializeComponent();
   }
   private void calculateButton_Click( object sender, EventArgs e )
   {
      Console.WriteLine(Convert.ToInt32( yearUpDown.Value ));
   } 
   private void InitializeComponent()
   {
      this.yearUpDown = new System.Windows.Forms.NumericUpDown();
      this.calculateButton = new System.Windows.Forms.Button();
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).BeginInit();
      this.SuspendLayout();
      this.yearUpDown.Location = new System.Drawing.Point(84, 97);
      this.yearUpDown.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
      this.yearUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.yearUpDown.Name = "yearUpDown";
      this.yearUpDown.ReadOnly = true;
      this.yearUpDown.Size = new System.Drawing.Size(100, 20);
      this.yearUpDown.TabIndex = 5;
      this.yearUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      this.yearUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.calculateButton.Location = new System.Drawing.Point(196, 16);
      this.calculateButton.Size = new System.Drawing.Size(75, 23);
      this.calculateButton.Text = "Calculate";
      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(289, 288);
      this.Controls.Add(this.calculateButton);
      this.Controls.Add(this.yearUpDown);
      this.Text = "Interest Calculator";
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
   }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


NumericUpDown.Minimum

  

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
   private System.Windows.Forms.NumericUpDown yearUpDown;
   private System.Windows.Forms.Button calculateButton;
   public Form1() {
      InitializeComponent();
   }
   private void calculateButton_Click( object sender, EventArgs e )
   {
      Console.WriteLine(Convert.ToInt32( yearUpDown.Value ));
   } 
   private void InitializeComponent()
   {
      this.yearUpDown = new System.Windows.Forms.NumericUpDown();
      this.calculateButton = new System.Windows.Forms.Button();
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).BeginInit();
      this.SuspendLayout();
      this.yearUpDown.Location = new System.Drawing.Point(84, 97);
      this.yearUpDown.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
      this.yearUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.yearUpDown.Name = "yearUpDown";
      this.yearUpDown.ReadOnly = true;
      this.yearUpDown.Size = new System.Drawing.Size(100, 20);
      this.yearUpDown.TabIndex = 5;
      this.yearUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      this.yearUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.calculateButton.Location = new System.Drawing.Point(196, 16);
      this.calculateButton.Size = new System.Drawing.Size(75, 23);
      this.calculateButton.Text = "Calculate";
      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(289, 288);
      this.Controls.Add(this.calculateButton);
      this.Controls.Add(this.yearUpDown);
      this.Text = "Interest Calculator";
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
   }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


NumericUpDown.ReadOnly

  
using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
   private System.Windows.Forms.NumericUpDown yearUpDown;
   private System.Windows.Forms.Button calculateButton;
   public Form1() {
      InitializeComponent();
   }
   private void calculateButton_Click( object sender, EventArgs e )
   {
      Console.WriteLine(Convert.ToInt32( yearUpDown.Value ));
   } 
   private void InitializeComponent()
   {
      this.yearUpDown = new System.Windows.Forms.NumericUpDown();
      this.calculateButton = new System.Windows.Forms.Button();
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).BeginInit();
      this.SuspendLayout();
      this.yearUpDown.Location = new System.Drawing.Point(84, 97);
      this.yearUpDown.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
      this.yearUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.yearUpDown.Name = "yearUpDown";
      this.yearUpDown.ReadOnly = true;
      this.yearUpDown.Size = new System.Drawing.Size(100, 20);
      this.yearUpDown.TabIndex = 5;
      this.yearUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      this.yearUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.calculateButton.Location = new System.Drawing.Point(196, 16);
      this.calculateButton.Size = new System.Drawing.Size(75, 23);
      this.calculateButton.Text = "Calculate";
      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(289, 288);
      this.Controls.Add(this.calculateButton);
      this.Controls.Add(this.yearUpDown);
      this.Text = "Interest Calculator";
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
   }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


NumericUpDown.TextAlign

  

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
   private System.Windows.Forms.NumericUpDown yearUpDown;
   private System.Windows.Forms.Button calculateButton;
   public Form1() {
      InitializeComponent();
   }
   private void calculateButton_Click( object sender, EventArgs e )
   {
      Console.WriteLine(Convert.ToInt32( yearUpDown.Value ));
   } 
   private void InitializeComponent()
   {
      this.yearUpDown = new System.Windows.Forms.NumericUpDown();
      this.calculateButton = new System.Windows.Forms.Button();
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).BeginInit();
      this.SuspendLayout();
      this.yearUpDown.Location = new System.Drawing.Point(84, 97);
      this.yearUpDown.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
      this.yearUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.yearUpDown.Name = "yearUpDown";
      this.yearUpDown.ReadOnly = true;
      this.yearUpDown.Size = new System.Drawing.Size(100, 20);
      this.yearUpDown.TabIndex = 5;
      this.yearUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      this.yearUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.calculateButton.Location = new System.Drawing.Point(196, 16);
      this.calculateButton.Size = new System.Drawing.Size(75, 23);
      this.calculateButton.Text = "Calculate";
      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(289, 288);
      this.Controls.Add(this.calculateButton);
      this.Controls.Add(this.yearUpDown);
      this.Text = "Interest Calculator";
      ((System.ruponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();
   }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


NumericUpDown.ThousandsSeparator

  

    using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  public class UpDownForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Label lblCurrSel;
    private System.Windows.Forms.Button btnGetSelections;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.NumericUpDown numericUpDown;
    public UpDownForm()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.label1 = new System.Windows.Forms.Label ();
      this.numericUpDown = new System.Windows.Forms.NumericUpDown ();
      this.btnGetSelections = new System.Windows.Forms.Button ();
      this.lblCurrSel = new System.Windows.Forms.Label ();
      numericUpDown.BeginInit ();
      label1.Location = new System.Drawing.Point (8, 80);
      label1.Text = "Numeric UpDown Control";
      label1.Size = new System.Drawing.Size (232, 32);
      label1.Font = new System.Drawing.Font ("Verdana", 12);
      label1.TabIndex = 3;
      numericUpDown.Location = new System.Drawing.Point (264, 80);
      numericUpDown.Maximum = new decimal (5000);
      numericUpDown.Size = new System.Drawing.Size (168, 20);
      numericUpDown.ThousandsSeparator = true;
      numericUpDown.TabIndex = 1;
      numericUpDown.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left;
      numericUpDown.ValueChanged += new System.EventHandler (this.numericUpDown_ValueChanged);
      btnGetSelections.Location = new System.Drawing.Point (16, 136);
      btnGetSelections.Size = new System.Drawing.Size (136, 24);
      btnGetSelections.TabIndex = 4;
      btnGetSelections.Text = "Get Current Selections";
      btnGetSelections.Click += new System.EventHandler (this.btnGetSelections_Click);
      lblCurrSel.Location = new System.Drawing.Point (176, 120);
      lblCurrSel.Size = new System.Drawing.Size (256, 48);
      this.Text = "Spin Controls";
      this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
      this.ClientSize = new System.Drawing.Size (448, 181);
      this.Controls.Add (this.lblCurrSel);
      this.Controls.Add (this.btnGetSelections);
      this.Controls.Add (this.label1);
      this.Controls.Add (this.numericUpDown);
      numericUpDown.EndInit ();
    }
    static void Main() 
    {
      Application.Run(new UpDownForm());
    }
    protected void numericUpDown_ValueChanged (object sender, System.EventArgs e)
    {
      this.Text = "You changed the numeric value...";
    }
    protected void btnGetSelections_Click (object sender, System.EventArgs e)
    {
      lblCurrSel.Text =  "Number: " 
        + numericUpDown.Value;
    }
  }


NumericUpDown.UpDownAlign

  

    using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  public class UpDownForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Label lblCurrSel;
    private System.Windows.Forms.Button btnGetSelections;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.NumericUpDown numericUpDown;
    public UpDownForm()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.label1 = new System.Windows.Forms.Label ();
      this.numericUpDown = new System.Windows.Forms.NumericUpDown ();
      this.btnGetSelections = new System.Windows.Forms.Button ();
      this.lblCurrSel = new System.Windows.Forms.Label ();
      numericUpDown.BeginInit ();
      label1.Location = new System.Drawing.Point (8, 80);
      label1.Text = "Numeric UpDown Control";
      label1.Size = new System.Drawing.Size (232, 32);
      label1.Font = new System.Drawing.Font ("Verdana", 12);
      label1.TabIndex = 3;
      numericUpDown.Location = new System.Drawing.Point (264, 80);
      numericUpDown.Maximum = new decimal (5000);
      numericUpDown.Size = new System.Drawing.Size (168, 20);
      numericUpDown.ThousandsSeparator = true;
      numericUpDown.TabIndex = 1;
      numericUpDown.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left;
      numericUpDown.ValueChanged += new System.EventHandler (this.numericUpDown_ValueChanged);
      btnGetSelections.Location = new System.Drawing.Point (16, 136);
      btnGetSelections.Size = new System.Drawing.Size (136, 24);
      btnGetSelections.TabIndex = 4;
      btnGetSelections.Text = "Get Current Selections";
      btnGetSelections.Click += new System.EventHandler (this.btnGetSelections_Click);
      lblCurrSel.Location = new System.Drawing.Point (176, 120);
      lblCurrSel.Size = new System.Drawing.Size (256, 48);
      this.Text = "Spin Controls";
      this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
      this.ClientSize = new System.Drawing.Size (448, 181);
      this.Controls.Add (this.lblCurrSel);
      this.Controls.Add (this.btnGetSelections);
      this.Controls.Add (this.label1);
      this.Controls.Add (this.numericUpDown);
      numericUpDown.EndInit ();
    }
    static void Main() 
    {
      Application.Run(new UpDownForm());
    }
    protected void numericUpDown_ValueChanged (object sender, System.EventArgs e)
    {
      this.Text = "You changed the numeric value...";
    }
    protected void btnGetSelections_Click (object sender, System.EventArgs e)
    {
      lblCurrSel.Text =  "Number: " 
        + numericUpDown.Value;
    }
  }


NumericUpDown.Validated

 

        
using System;
using System.ruponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Text;
class DialogValid : System.Windows.Forms.Form
{
    private Button okButton;
    private Button cancelButton;
    private NumericUpDown num;
    public decimal Num {
        get { return num.Value; }
        set { num.Value = value;    }
    }
    void OnValidating(Object sender, CancelEventArgs e)
    {
        MessageBox.Show("NumericUpDown is validating");
    } 
    void OnValid(Object sender,EventArgs e)
    {
        MessageBox.Show("NumericUpDown is valid");
    } 
    public DialogValid()
    {
        Size = new Size(400,100);
        FormBorderStyle = FormBorderStyle.FixedDialog;
        Text = "Dialog test";
        okButton = new Button();        
        okButton.DialogResult = DialogResult.OK;
        okButton.Location = new Point(20,28);
        okButton.Size = new Size(80,25);
        okButton.Text = "OK";
        Controls.Add(okButton);
        cancelButton = new Button();
        cancelButton.Location = new Point(300,28);
        cancelButton.Size = new Size(80,25);
        cancelButton.Text = "Cancel";
        cancelButton.DialogResult = DialogResult.Cancel;
        Controls.Add(cancelButton);
        Label l = new Label();
        l.Text = "NumericUpDown";
        l.Location = new Point(20,5);
        l.Size = new Size(120,25);
        Controls.Add(l);
        num = new NumericUpDown();
        num.Location = new Point(140,5);
        num.Size = new Size(80,25);
        num.Minimum = (decimal)10.0;
        num.Maximum = (decimal)100.0;
        num.Value = (decimal)10.0;
        
        num.Validating+=new CancelEventHandler(OnValidating);
        num.Validated+=new EventHandler(OnValid);
        Controls.Add(num);
    }
}
public class NumericUpDownValidationEvent{
    public static void Main()
    {
        DialogValid dlg = new DialogValid();
        DialogResult r = dlg.ShowDialog();
        
        Console.WriteLine(dlg.Num);
    }
}


NumericUpDown.Validating

 

        
using System;
using System.ruponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Text;
class DialogValid : System.Windows.Forms.Form
{
    private Button okButton;
    private Button cancelButton;
    private NumericUpDown num;
    public decimal Num {
        get { return num.Value; }
        set { num.Value = value;    }
    }
    void OnValidating(Object sender, CancelEventArgs e)
    {
        MessageBox.Show("NumericUpDown is validating");
    } 
    void OnValid(Object sender,EventArgs e)
    {
        MessageBox.Show("NumericUpDown is valid");
    } 
    public DialogValid()
    {
        Size = new Size(400,100);
        FormBorderStyle = FormBorderStyle.FixedDialog;
        Text = "Dialog test";
        okButton = new Button();        
        okButton.DialogResult = DialogResult.OK;
        okButton.Location = new Point(20,28);
        okButton.Size = new Size(80,25);
        okButton.Text = "OK";
        Controls.Add(okButton);
        cancelButton = new Button();
        cancelButton.Location = new Point(300,28);
        cancelButton.Size = new Size(80,25);
        cancelButton.Text = "Cancel";
        cancelButton.DialogResult = DialogResult.Cancel;
        Controls.Add(cancelButton);
        Label l = new Label();
        l.Text = "NumericUpDown";
        l.Location = new Point(20,5);
        l.Size = new Size(120,25);
        Controls.Add(l);
        num = new NumericUpDown();
        num.Location = new Point(140,5);
        num.Size = new Size(80,25);
        num.Minimum = (decimal)10.0;
        num.Maximum = (decimal)100.0;
        num.Value = (decimal)10.0;
        
        num.Validating+=new CancelEventHandler(OnValidating);
        num.Validated+=new EventHandler(OnValid);
        Controls.Add(num);
    }
}
public class NumericUpDownValidationEvent{
    public static void Main()
    {
        DialogValid dlg = new DialogValid();
        DialogResult r = dlg.ShowDialog();
        
        Console.WriteLine(dlg.Num);
    }
}


NumericUpDown.Value

   
using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
  private System.Windows.Forms.GroupBox GroupBox1;
  private System.Windows.Forms.Button cmdApply;
  private System.Windows.Forms.NumericUpDown udOpacity;
  private System.Windows.Forms.Label Label1;
  public Form1() {
        InitializeComponent();
  }

  private void cmdApply_Click(object sender, EventArgs e)
  {
    this.Opacity = (double)udOpacity.Value / 100;
  }
  private void InitializeComponent()
  {
    this.GroupBox1 = new System.Windows.Forms.GroupBox();
    this.cmdApply = new System.Windows.Forms.Button();
    this.udOpacity = new System.Windows.Forms.NumericUpDown();
    this.Label1 = new System.Windows.Forms.Label();
    this.GroupBox1.SuspendLayout();
    ((System.ruponentModel.ISupportInitialize)(this.udOpacity)).BeginInit();
    this.SuspendLayout();
    // 
    // GroupBox1
    // 
    this.GroupBox1.Controls.Add(this.cmdApply);
    this.GroupBox1.Controls.Add(this.udOpacity);
    this.GroupBox1.Controls.Add(this.Label1);
    this.GroupBox1.Location = new System.Drawing.Point(12, 89);
    this.GroupBox1.Name = "GroupBox1";
    this.GroupBox1.Size = new System.Drawing.Size(268, 116);
    this.GroupBox1.TabIndex = 5;
    this.GroupBox1.TabStop = false;
    // 
    // cmdApply
    // 
    this.cmdApply.Location = new System.Drawing.Point(172, 64);
    this.cmdApply.Name = "cmdApply";
    this.cmdApply.Size = new System.Drawing.Size(80, 24);
    this.cmdApply.TabIndex = 5;
    this.cmdApply.Text = "Apply";
    this.cmdApply.Click += new System.EventHandler(this.cmdApply_Click);
    // 
    // udOpacity
    // 
    this.udOpacity.Increment = new decimal(new int[] {
        5,
        0,
        0,
        0});
    this.udOpacity.Location = new System.Drawing.Point(88, 32);
    this.udOpacity.Name = "udOpacity";
    this.udOpacity.Size = new System.Drawing.Size(48, 21);
    this.udOpacity.TabIndex = 4;
    this.udOpacity.Value = new decimal(new int[] {
        50,
        0,
        0,
        0});
    // 
    // Label1
    // 
    this.Label1.Location = new System.Drawing.Point(20, 36);
    this.Label1.Name = "Label1";
    this.Label1.Size = new System.Drawing.Size(56, 16);
    this.Label1.TabIndex = 3;
    this.Label1.Text = "Opacity:";
    // 
    // Transparent
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(309, 289);
    this.Controls.Add(this.GroupBox1);
    this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Name = "Transparent";
    this.Text = "Transparent";
    this.GroupBox1.ResumeLayout(false);
    ((System.ruponentModel.ISupportInitialize)(this.udOpacity)).EndInit();
    this.ResumeLayout(false);
  }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}


NumericUpDown.ValueChanged

  

    using System;
  using System.Drawing;
  using System.Collections;
  using System.ruponentModel;
  using System.Windows.Forms;
  using System.Data;
  public class UpDownForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Label lblCurrSel;
    private System.Windows.Forms.Button btnGetSelections;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.NumericUpDown numericUpDown;
    public UpDownForm()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.label1 = new System.Windows.Forms.Label ();
      this.numericUpDown = new System.Windows.Forms.NumericUpDown ();
      this.btnGetSelections = new System.Windows.Forms.Button ();
      this.lblCurrSel = new System.Windows.Forms.Label ();
      numericUpDown.BeginInit ();
      label1.Location = new System.Drawing.Point (8, 80);
      label1.Text = "Numeric UpDown Control";
      label1.Size = new System.Drawing.Size (232, 32);
      label1.Font = new System.Drawing.Font ("Verdana", 12);
      label1.TabIndex = 3;
      numericUpDown.Location = new System.Drawing.Point (264, 80);
      numericUpDown.Maximum = new decimal (5000);
      numericUpDown.Size = new System.Drawing.Size (168, 20);
      numericUpDown.ThousandsSeparator = true;
      numericUpDown.TabIndex = 1;
      numericUpDown.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left;
      numericUpDown.ValueChanged += new System.EventHandler (this.numericUpDown_ValueChanged);
      btnGetSelections.Location = new System.Drawing.Point (16, 136);
      btnGetSelections.Size = new System.Drawing.Size (136, 24);
      btnGetSelections.TabIndex = 4;
      btnGetSelections.Text = "Get Current Selections";
      btnGetSelections.Click += new System.EventHandler (this.btnGetSelections_Click);
      lblCurrSel.Location = new System.Drawing.Point (176, 120);
      lblCurrSel.Size = new System.Drawing.Size (256, 48);
      this.Text = "Spin Controls";
      this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
      this.ClientSize = new System.Drawing.Size (448, 181);
      this.Controls.Add (this.lblCurrSel);
      this.Controls.Add (this.btnGetSelections);
      this.Controls.Add (this.label1);
      this.Controls.Add (this.numericUpDown);
      numericUpDown.EndInit ();
    }
    static void Main() 
    {
      Application.Run(new UpDownForm());
    }
    protected void numericUpDown_ValueChanged (object sender, System.EventArgs e)
    {
      this.Text = "You changed the numeric value...";
    }
    protected void btnGetSelections_Click (object sender, System.EventArgs e)
    {
      lblCurrSel.Text =  "Number: " 
        + numericUpDown.Value;
    }
  }