1: /// <summary>
2: /// 可以输入小数和整数(不包括负数)
3: /// </summary>
4: /// <param name="e"></param>
5: public static void ControlTextBoxDigital(System.Windows.Forms.KeyPressEventArgs e)
6: {
7: if (e.KeyChar != 46 && !char.IsDigit(e.KeyChar) && e.KeyChar != 8)
8: e.Handled = true;
9: }
10:
11:
12: /// <summary>
13: /// 只能输入整数(不包括负数)
14: /// </summary>
15: /// <param name="e"></param>
16: public static void ControlTextBoxInt(System.Windows.Forms.KeyPressEventArgs e)
17: {
18: //保证这里只能输入数字
19: if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == 8))
20: {
21: e.Handled = true;
22: }
23: }