silverlight 文本框只能输入汉字
2020-11-15 21:55
标签:com http blog style class div img code log c tar silverlight 文本框只能输入汉字,搜素材,soscw.com silverlight 文本框只能输入汉字 标签:com http blog style class div img code log c tar 原文地址:http://www.cnblogs.com/zxbzl/p/3699397.html private void txtName_KeyDown(object sender, KeyEventArgs e)
{
Regex rg = new Regex("^[\u4e00-\u9fa5\b]$"); //\b是退格键
if (!rg.IsMatch(e.Key.ToString()))
{
e.Handled = true;
}
if (txtName.Text.Length >= 20)
{
txtName.Text = txtName.Text.Substring(0, 20);
EasySL.Controls.Window.Alert("请输入20内的名称", this.floatePanel);
}
}