繁体   English   中英

冻结Windows窗体C#

[英]Freezing windows form c#

我试图在LoadNewQCDetails();冻结表单LoadNewQCDetails(); 方法正在处理中; 但是,即使在完成LoadNewQCDetails();之后禁用或暂停了UI,也是LoadNewQCDetails(); 方法,由用户触发的所有点击事件。 因此,我需要冻结表单,以便用户在LoadNewQCDetails();之前不能在UI中单击任何内容LoadNewQCDetails(); 处理完成。

我的代码:

    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();
}
this.hide()
 //shows the main page
  LoadNewQCDetails();
this.show()

将所有控件添加到面板中,然后执行panel.enabled = false;。 就在调用您的方法和panel.enabled = true之前; 在方法调用之后。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM