我有以下代碼:取消形式負載
該呼叫的第二形式
private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
Update fm = new Update();
fm.ShowDialog();
}
這是構造
public Update()
{
InitializeComponent();
}
這是負載
private void Update_Load(object sender, EventArgs e)
{
String ver = checkver();
if (ver == "update")
{
if (RemoteFileExists(dlUrl) == true)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri(dlUrl), "");
}
else
MessageBox.Show("An error occurred. Please try later.");
}
else if (ver == "newest")
{
MessageBox.Show("You are currently using the newest version.");
this.Close();
}
else
{
this.Close();
}
}
我的問題是,當功能n結果爲2或3,表單顯示爲毫秒,然後關閉(閃爍)。我希望表單不閃爍。可能嗎?
我試圖用this.Hide(),THIS.VISIBLE =假但沒有任何幫助。
編輯:我把原來的代碼 EDIT2:把更多的代碼
笑什麼情況?爲什麼我不能寫「你好人」? :) – a1204773
將代碼放在窗體構造函數中,這會在form_load事件發生之前調用(取決於funct()中發生了什麼......如果它依賴於訪問尚未初始化的組件,那麼這會贏得'工作)。 –
您應該只調用一次funct(),以便您切換的值保證是相同的,除非您特別想要它可以更改的可能性。 – 3Pi