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

后端 未结 2 1150
醉酒成梦
醉酒成梦 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: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.

提交回复
热议问题