我试图在公共静态int入口变量为0时尝试清除错误提供程序(此变量是静态的,因为我正在从另一个表单中更改它的值:<\ n / p>
private void Profile_FormClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
Form1.entry = 0;
}
)
所以在我的主窗体中,当我按下这样的按钮时,我将该入口变量设置为1:
private void button21_Click(object sender, EventArgs e)
{
if((TransferHair!=String.Empty)&& (TransferName != String.Empty))
{
if (entry == 0)
{
Profile pro = new Profile();
pro.Show();
entry = 1;
errorProvider1.Clear();
}
else
{
//MessageBox.Show("You can't open more than 1 profile box!");
errorProvider1.SetError(button21, "Close the previous profile before opening another!");
}
}
}
但我确实希望在关闭配置文件表单时立即清除该错误并且我这样做:
private void entry_ValueChanged(object sender,EventArgs e)
{
if (entry == 0)
{
errorProvider1.Clear();
}
}
它不起作用!
我也这样做了:
public int TheEntry
{
get { return entry; }
set
{
if(entry == 0)
{
// entry = 0;
errorProvider1.Clear();
}
}
}
仍然无法正常工作!
我需要一个解决方案!