我想表明一種叫做TTT
所以我嘗試這樣的:C#中打開窗體並關閉它
public static TTT ttt_local = new TTT();
private void button1_Click(object sender, EventArgs e)
{
ttt_local.Show();
}
然後我想從裏面關的形式,以便ttt_local
自行關閉時ttt_local
按下按鈕。這有效,但如果我想重新打開ttt_local
我得到ObjectDisposedException
。有人能幫助我嗎?
'ttt_local.Dispose();' –
顯示如何關閉窗體。我想你需要的是**隱藏**的形式,而不是**閉幕**。 – HimBromBeere
永遠不要寫這樣的代碼,一個Form對象是一次性的。一旦關閉,它就不再可用。並嘗試再次使用它會產生ODE。在需要時創建對象。如果您想強制執行單實例行爲,請訂閱FormClosed事件以將ttt_local變量設置爲null。 –