在C# 中 如何限制在文本框(textBox)中输入的类型为正整数时间:2023-03-08 23:07:33 在文本框的 KeyPress 事件中写下这些代码就可以保证是正整数了 private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b')) { e.Handled = true; } }