private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar > 0 && e.KeyChar < 7) || (e.KeyChar > 9 && e.KeyChar < 177)) { e.Handled = true; MessageBox.Show("姓名只能输入汉字"); } } 来自王绚文老师博客