ErrorProvider实际上并不是一个控件, 而是一个组件. 当把组件拖放到设计器上时, 它会显示在设计器下方的组件栏中.
当存在一个错误条件时, ErrorProvider可以在控件的旁边显示一个图标.
例: 这里errAllInfo是一个ErrorProvider组件.
Code
if (this.txtUid.Text.Length == 0)
{
this.errAllInfo.SetError(this.txtUid, "用户名不能为空!");
}
if (this.txtPwd.Text.Length < 6)
{
this.errAllInfo.SetError(this.txtPwd, "密码不能小于6位!");
}
当存在一个错误条件时, ErrorProvider可以在控件的旁边显示一个图标.
例: 这里errAllInfo是一个ErrorProvider组件.


if (this.txtUid.Text.Length == 0)
{
this.errAllInfo.SetError(this.txtUid, "用户名不能为空!");
}
if (this.txtPwd.Text.Length < 6)
{
this.errAllInfo.SetError(this.txtPwd, "密码不能小于6位!");
}