silverlight 文本框只能输入汉字
时间:2014-04-30 16:16:38
收藏:0
阅读:398
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); } }
评论(0)