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

}

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM