NumericUpDown.TextAlign
using System;
using System.Collections.Generic;
using System.ComponentModel;
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.ComponentModel.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.ComponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
Related examples in the same category