C# MDI Parent detect when MDI Child is closing?

前端 未结 6 1139
青春惊慌失措
青春惊慌失措 2021-01-18 10:18

I\'m attempting to detect, on the MDI parent, when my MDI child form closes, and react accordingly. The MDI parent shouldn\'t do anything until the MDI child closes. Here is

6条回答
  •  粉色の甜心
    2021-01-18 10:45

    Don't use the Closed Event. Instead, use the FormClosing event:

    private void frmMain_FormClosing(object sender, FormClosingEventArgs e){
      if (MessageBox.Show("Are you sure you want to Exit", "Confirmation", MessageBoxButtons.YesNo,MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.No) {
        e.Cancel = true;
      }
    }
    

提交回复
热议问题