errorProName(错误显示)

errorProName:指示代码中用来标识该对象的名称;
errorProName.SetError(txtName, "用户名不能为空"); ——设置指定空间的错误描述字符串;
errorProName.Clear();——清除与此组件相关联的所有设置;

if (txtName.Text=="")
            {
                errorProName.SetError(txtName, "用户名不能为空");
            }
            else
            {
                errorProName.Clear();
                string strSql = "select * from tb_admin where name='" + txtName.Text + "'and pwd='" + txtPwd.Text + "'";
                DataSet ds = dataoperate.getDs(strSql,"tb_admin");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    this.Hide();
                    frmMain frmmain = new frmMain();
                    frmmain.Show();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning );
                }
            }
#Winform

你可能感兴趣的:(error)