private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar)))
{
e.Handled = true;
}
}
限制不能輸入英文字母(可輸入符號~空白鍵...):
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
e.Handled = true;
}
}
沒有留言:
張貼留言