现在的位置: 首页 > 综合 > 正文

C#文本框输入验证控件的使用

2012年11月16日 ⁄ 综合 ⁄ 共 519字 ⁄ 字号 评论关闭
 1private void textBox2_Validating(object sender, CancelEventArgs e)
 2        {
 3            if (textBox2.TextLength>0 && (textBox2.TextLength!=5))
 4            {
 5                errorProvider1.SetIconAlignment((Control)sender,ErrorIconAlignment.MiddleRight);
 6                errorProvider1.SetError((Control)sender,"TextLength>0 && TextLength!=5");
 7                e.Cancel=true;
 8            }

 9            else
10            {
11                errorProvider1.SetError((Control)sender,"");
12            }

13        }

抱歉!评论已关闭.