实现效果:

  

知识运用:

  ErrorProvider组件的BlinkStyle属性    //指示错误图标的闪烁时间

  public ErrorBlinkStyle BlinkStyle{ get;set; }

  

  BlinkRate属性      //图标的闪烁频率 (毫秒为单位)

  public int BlinkRate {get; set;}

  SetError方法    //将Error属性设置为指定的TextWriter对象

  public static void SetError(TextWriter newError)

  TextBox文本框的Validating事件  //在控件正在发生验证时发生

  public event CancelEventHandler Validating

实现代码:

        string strA = null;
string strB = null; private void txtPwd_Validating(object sender, CancelEventArgs e)
{
if (txtPwd.Text != "microsoft")
{
errorProvider1.SetError(txtPwd, "密码错误");
}
else
{
errorProvider1.SetError(txtPwd, ""); //不显示任何内容
strB = txtPwd.Text;
}
} private void txtUser_Validating(object sender, CancelEventArgs e)
{
if (txtUser.Text != "soft")
{
errorProvider1.SetError(txtUser, "用户名错误");
}
else
{
errorProvider1.SetError(txtUser, ""); //不显示任何内容
strA = txtUser.Text;
}
}

最新文章

  1. Gollum 安装笔记
  2. Linux中常用操作命令
  3. 手把手教你搭建SpringMVC——最小化配置
  4. Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_GiftAnimationView"
  5. androidd 程序默认安装位置和数据存储位置(公用和私用)
  6. 单元测试中使用Moq对EF的DbSet进行mock
  7. 【网络流24题】No.7 试题库问题 (最大流,二分图多重匹配)
  8. 交叉编译:cannot find /lib/libc.so.6 collect2: ld returned 1 exit status
  9. 在PyQt4中使用matplotlib
  10. 关于JAVA中split方法使用竖线异常的问题
  11. leetcode371
  12. VLAN之间单臂路由通信
  13. 3分钟学会做智能插座(DIY)
  14. git根据用户过滤提交记录
  15. MySQL Split 函数
  16. mac下/usr/local/bin No such file or directory问题解决
  17. PR使用技巧
  18. 【MySQL学习杂记】 2017年7月13日
  19. Linux下 sleep函数的注意事项
  20. Windbg查看w3wp进程占用的内存及.NET内存泄露,死锁分析

热门文章

  1. Java8函数式接口之Predicate<T>
  2. Guid.NewGuid().ToString()的几种格式 (转)
  3. 集成Python Shell
  4. encodeURI和uncodeURIComponent的介绍
  5. AI决策算法 之 GOAP (一)
  6. 洛谷P3405 [USACO16DEC]Cities and States省市
  7. 平衡的阵容 st表学习
  8. Django一些鲜为人知的操作
  9. Avito Cool Challenge 2018-A. Definite Game(思维题)
  10. Spring boot中应用jpa jpa用法