textbox只能输入汉字

 private void txt_username_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar > 0 && e.KeyChar < 7) || (e.KeyChar > 9 && e.KeyChar < 177))
            {
                e.Handled = true;
                MessageBox.Show("姓名只能输入汉字");
            }
        }
posted @ 2010-06-02 10:35  王绚文  阅读(271)  评论(0编辑  收藏  举报