日期:2014-05-17 浏览次数:20855 次
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Key != Key.Back && e.Key < Key.D0 || e.Key > Key.D9 && e.Key < Key.NumPad0 || e.Key > Key.NumPad9) { e.Handled = true; } } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8) { e.Handled = true; } }
private void textBox1_KeyDown(object sender, KeyPressEventArgs e) { if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar)) { e.Handled = true; } }