C# TextBox中只能输入数字的几种常用方法(C#)
if (text != null)MessageBox.Show(text);}private void textBox1_Validating(object sender, CancelEventArgs e){const string pattern = @"^\\d+\\.?\\d+$";string content = ((TextBox)sender).Text;if (!(Regex.IsMatch(content, pattern))){errorProvider1.SetError((Control)sender, "只能...
C#winform中ErrorProvider控件的用法?
errorProvider2.SetError(textBox2, "通过验证");errorProvider2.SetError(textBox3, "通过验证");x = 1;errorProvider2.Icon = new Icon(@"D:\\exe创建\\13第十三章\\13.12 ErrorProvider控件\\ico\\true.ico");} if (textBox3.Text == null){ errorProvider2.SetError(textBox3, " ");x =...
c# winform中如何判断输入的信息是否为姓名格式 电话格式 年龄格式_百度...
private void tBox_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar == 0x20) e.KeyChar = (char)0; \/\/禁止空格键 if ((e.KeyChar == 0x2D) && (((TextBox)sender).Text.Length == 0)) return; \/\/处理负数 if (e.KeyChar > 0x20){ try { double.Parse((...