/// <summary> /// 限制只能输入数字 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxNum_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar)) { e.Handled = true; } }
/// <summary> /// 限制只能输入数字 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxNum_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar)) { e.Handled = true; } }