判断文本框输入是否为汉字

判断文本框输入的内容是否为汉字,利用文本框的键盘事件KeyPressEventArgs;

   public static bool IsChinese(KeyPressEventArgs e,DevExpress.XtraEditors.TextEdit text)
        {
            if ((e.KeyChar >= (char)0x4e00) && (e.KeyChar <= (char)0x9fa5) || (byte)(e.KeyChar) == 8)
            {
                e.Handled = false;
                return true;
            }
            else
            {
                e.Handled = true;
                return false;
            }
        }


原文地址:https://www.cnblogs.com/dengshiwei/p/4258790.html