我需要隐藏提交,但是如果在验证中有任何错误。我正在使用下面的代码,如果我输入了两个带有字符的文本框,并且如果我更正了文本框中的提交按钮,就会看到!如何避免它util所有的错误是明确的? 谢谢如果验证中有任何错误,请禁用提交按钮
int num;
private void textBox5_TextChanged(object sender, EventArgs e)
{
bool isNum = int.TryParse(textBox5.Text.Trim(), out num);
if (!isNum)
{
button2.Visible = false;
errorProvider1.SetError(this.textBox5, "Please enter numbers");
}
else
{
button2.Visible = true;
errorProvider1.SetError(this.textBox5, "");
}
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
bool isNum = int.TryParse(textBox6.Text.Trim(), out num);
if (!isNum)
{
button2.Visible = false;
errorProvider2.SetError(this.textBox6, "Please enter numbers");
}
else
{
button2.Visible = true;
errorProvider2.SetError(this.textBox6, "");
}
}
“System.Windows.Forms.TextBox”不包含“GetError”和没有扩展方法定义的所有TextChanged事件的这种方法“GetError”接受第一可以找到'System.Windows.Forms.TextBox'类型的参数 – JIMMY 2014-11-09 07:31:35