Running Code From A Particular Context After A Form Closes?

后端 未结 1 1362
暗喜
暗喜 2021-01-23 10:46

I want to run some code in this context after the form created here closes.

Form1 Form1 = new Form1();
Form1.Show(); //<-After this closes, I want to run co         


        
相关标签:
1条回答
  • 2021-01-23 11:34

    just register for the FormClosing event of the Form

    void MyClosingEvent(object o, FormClosingEventArgs args)
    {
    }
    
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form1 form1 = new Form1();
        form1.FormClosing += new FormClosingEventHandler(MyClosingEvent);
        //Or if you have C# 2 or higher: 
        //form1.FormClosing += MyClosingEvent;
    
    0 讨论(0)
提交回复
热议问题