// [Delete List Data] Menu Item private void deleteListDataToolStripMenuItem_Click(object sender, EventArgs e) { if (formDeleteListData == null) { formDeleteListData = new DeleteListData(); formDeleteListData.MdiParent = this; // In the current context += means subscribe. In other words it's like you are telling subscribe my method (the right operand) // to this event (the left operand), this way, when the event is raised, your method will be called. Also, it is a good practice // to unsubscribe (-= from this event, when you have finished your work ( but before you dispose you object ) in order to prevent // your method being called and to prevent resource leaks. formDeleteListData.FormClosed += formDeleteListData_FormClosed; formDeleteListData.Show(); } else { // if the Form is already open formDeleteListData.Activate(); } }
// [Delete List Data] private void formDeleteListData_FormClosed(object sender, FormClosedEventArgs e) { formDeleteListData = null; }