How can I get code to run after a form is shown? (Trouble with “Shown”.)

后端 未结 2 1125
醉酒成梦
醉酒成梦 2021-01-25 13:02

I thought Shown would be the answer. But it seems that not all controls are equal. A panel is shown immediately, while a label – not.

I have the fo

相关标签:
2条回答
  • 2021-01-25 13:41

    Add the following at the beginning of the event handler:

    this.Update();
    
    0 讨论(0)
  • 2021-01-25 13:45
    void Form2_Shown(object sender, EventArgs e)
    {
        Application.DoEvents();
        System.Threading.Thread.Sleep(2000);
    }
    

    I think that gets you what you want , but IMHO if you have a lengthy operation you should start another thread.

    0 讨论(0)
提交回复
热议问题