C#关闭事件处理程序不工作

C#关闭事件处理程序不工作,c#,event-handling,formclosing,C#,Event Handling,Formclosing,我希望在用户关闭当前窗体时将主菜单窗体大小设置为正常大小。我尝试了各种方法来处理关闭事件,但是似乎没有什么效果。表单仍然关闭,并且没有显示消息框,提醒我函数已经运行 主菜单窗体打开,但在用户使用当前窗体时最小化 我的结束事件处理程序 private void frm_createCust_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true;

我希望在用户关闭当前窗体时将主菜单窗体大小设置为正常大小。我尝试了各种方法来处理关闭事件,但是似乎没有什么效果。表单仍然关闭,并且没有显示消息框,提醒我函数已经运行

主菜单窗体打开,但在用户使用当前窗体时最小化

我的结束事件处理程序

private void frm_createCust_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
            MessageBox.Show("Closing");
            frm_MainMenu frm_MainMenu = new frm_MainMenu();
            frm_MainMenu.WindowState = FormWindowState.Normal;
            frm_MainMenu.Show();
            //this.Close();            
        } 

提前感谢。

关闭时,子窗体不应该试图影响其父窗体,而应该由父窗体处理该逻辑,并在其代码中应用事件处理程序:


关闭时,子窗体不应试图影响其父窗体,相反,父窗体应处理该逻辑,并在其代码中应用事件处理程序:


这是你想要的吗?表单是否处于父/子关系中

this.ParentForm.WindowState = FormWindowState.Normal;

这是你想要的吗?表单是否处于父/子关系中

this.ParentForm.WindowState = FormWindowState.Normal;

是的,这是一个更好的解决方案。哦,我在设计器中犯了一个错误,this.FormClosing+=new System.Windows.Forms.formclosingerventhandler(this.frm_createCust_FormClosing);我让它工作起来了,谢谢大家:)没有注意到还有另外一个表单。是的,这是一个更好的解决方案。哦,我在设计器中犯了一个错误,this.FormClosing+=new System.Windows.Forms.FormClosingEventHandler(this.frm\u createCust\u FormClosing);我让它工作起来了,谢谢大家:)我没有注意到还有另外一个表单。