2014-05-22 3 views
1

사용자가 현재를 닫을 때 기본 메뉴 양식 크기를 보통으로 만들고 싶습니다. 그러나 Closing 이벤트와 관련하여 다양한 방법을 시도해 봤지만 양식이 여전히 닫히고 메시지 상자가 표시되지 않으며 기능이 실행되었음을 알립니다.C# 이벤트 핸들러가 작동하지 않음

주 메뉴 양식은 열려 있지만 사용자가 현재 양식을 사용할 때 최소화됩니다.

내 closing 이벤트 핸들러;

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();    
     } 

미리 감사드립니다.

답변

4

이 닫힐 때 부모가 코드 이벤트 핸들러를 적용 할 하나를 그 논리를 처리하고 있어야한다 오히려 아이 양식, 부모에 영향을하려고해서는 안 :

//somewhere in your main form's code: 
SomeChildForm child = new SomeChildForm(); 
child.FormClosing += (s, args) => 
{ 
    WindowState = FormWindowState.Normal; 
    Show(); 
}; 
child.Show(); 
+0

네 이것은 더 나은 해결책입니다. – NeutronCode

+0

죄송합니다. 디자이너에서 this.FormClosing + = new System.Windows.Forms.FormClosingEventHandler (this.frm_createCust_FormClosing); 내가 일하고있어, 고마워 어쨌든 사람 : – Seatter

+0

거기에 관련된 다른 형태가 통보하지 않았다. – Bolu

0

을 이게 니가 원하는거야? 부모/자녀 관계에있는 양식입니까?

this.ParentForm.WindowState = FormWindowState.Normal;