C# numericUpDown控制元件的使用
阿新 • • 發佈:2018-11-10
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(); } } privatevoid 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(); } } }