// When the New menu item is clicked, create a new MDI child. private void mnuNew_Click(object sender, EventArgs e) { Recipe07_05Child frm = new Recipe07_05Child(); frm.MdiParent = this; frm.Show(); }
// When a button on any of the MDI child forms is clicked, display the // contents of a each form by enumerating the MdiChildren collection. private void cmdShowAllWindows_Click(object sender, EventArgs e) { foreach (Form frm in this.MdiParent.MdiChildren) { // Cast the generic Form to the Recipe07_05Childderived class // type. Recipe07_05Child child = (Recipe07_05Child)frm; MessageBox.Show(child.LabelText, frm.Text); } }