using System; using System.Windows.Forms; namespace closeissue { public class Form1 : Form { public Form1() { this.IsMdiContainer = true; this.Load += new System.EventHandler(this.Form1_Load_1); } private void Form1_Load_1(object sender, EventArgs e) { Form x =new Form2(); x.MdiParent = this; x.Show(); } } public class Form2 : Form { public Form2() { dataGrid1=new DataGrid() ; this.form1BindingSource = new System.Windows.Forms.BindingSource(); this.dataGrid1.DataMember = ""; this.dataGrid1.DataSource = this.form1BindingSource; this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill; this.form1BindingSource.DataSource = typeof(createdobjectstotshown.Form1); this.Controls.Add(this.dataGrid1); this.KeyPreview = true; this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form2_KeyPress); } private System.Windows.Forms.DataGrid dataGrid1; private System.Windows.Forms.BindingSource form1BindingSource; private void Form2_KeyPress(object sender, KeyPressEventArgs e) { Close(); } } static class Program { static void Main() { Application.Run(new Form1()); } } }