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

判断文本框输入的内容是否为汉字,利用文本框的键盘事件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;
            }
        }



 

posted @ 2014-04-11 15:16  静以养身 俭以养德  阅读(152)  评论(0编辑  收藏  举报