我正在尝试在LoadNewQCDetails();
方法正在进行时冻结表单;但是,即使在完成LoadNewQCDetails();
方法后禁用/暂停UI,用户的所有点击事件也会触发。所以,
我需要冻结表单,以便用户在LoadNewQCDetails();
进程完成之前无法点击UI中的任何内容。
我的代码:
private void button5_Click(object sender, EventArgs e)
{
//this.SuspendLayout();
//this.Enabled = false;
button3.Enabled = false;
tabControl1.Enabled = false;
groupBox1.Enabled = false;
groupBox2.Enabled = false;
groupBox3.Enabled = false;
GlobalVariable.RefreshArtiCnt = 0;
if (comboBox2.Text != "" )
{
// LoadAllQCDetails();
//this function takes nearly 1 minute to complete task
LoadNewQCDetails();
}
else
{ MessageBox.Show("Data not found for this condition", "Alert"); }
button3.Enabled = true;
tabControl1.Enabled = true;
groupBox1.Enabled = true;
groupBox2.Enabled = true;
groupBox3.Enabled = true;
//this.Enabled = true;
// this.ResumeLayout();
}
答案 0 :(得分:0)
this.hide()
//shows the main page
LoadNewQCDetails();
this.show()
答案 1 :(得分:0)
在面板中添加所有控件并执行panel.enabled = false;在调用你的方法和panel.enabled = true之前;方法调用后。