2010-06-07 156 views
2

當我啓動我的應用程序時,我在使用的控件上出現了一個小滯後。我可以在之後顯示主窗體的控件嗎?啓動時控制初始化滯後

+0

你是說當主窗體出現時,控件不會立即顯示? – egrunin 2010-06-07 18:25:52

+0

我想是的。顯示窗體後,控件就會出現。 – blez 2010-06-07 18:49:19

回答

1

嘗試在表單的加載方法中訂閱Application.Idle事件,並在調用後取消訂閱。像這樣:

public Form() 
{ 
    InitializeComponent(); 
} 

private void Form_Load(object sender, EventArgs e) 
{ 
    Application.Idle += new EventHandler(Application_Idle); 
    // any loading prep code here 
} 

private void Application_Idle(object sender, EventArgs e) 
{ 
    Application.Idle -= new EventHandler(Application_Idle); 
    // additional code here, which is executed *after* controls are visible and loaded 
}