首先引用 using System.Text.RegularExpressions; 给TextBox添加KeyPress事件,代码如下: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) } 相关文章: