C# numericUpDown控件的使用

namespace WindowsFormsApplication106
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
numericUpDown1.DecimalPlaces = int.Parse(textBox1.Text);
}
catch
{
MessageBox.Show("输入的值有误");
textBox1.Clear();
}
}

private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "将显示的值";
}

private void button2_Click(object sender, EventArgs e)
{
try{
numericUpDown1.Increment = int.Parse(textBox2.Text);
}

catch
{
MessageBox.Show("输入的值有误");
textBox2.Clear();
}
}

private void button3_Click(object sender, EventArgs e)
{
numericUpDown1.UpButton();
}

private void button4_Click(object sender, EventArgs e)
{
numericUpDown1.DownButton();
}

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
label1.Text = numericUpDown1.Value.ToString();
}

}

}

猜你喜欢

转载自www.cnblogs.com/wpc0228/p/9816460.html