突然想了一下,这样就是不管你有几级,都会关掉,如果只想关掉自己和父窗体,可以用下面的办法:
将form1传入form2,关的时候把两个都关了,代码如下:

解决方案 »

  1.   

    form1中:
            private void button1_Click(object sender, EventArgs e)
            {
                Form2 f = new Form2(this);
                f.Show();
            }
    form2中:
             Form1 f1 = null;
            public Form2()
            {
                InitializeComponent();
            }
            public Form2(Form1 f)
            {
                InitializeComponent();
                f1 = f;
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
                f1.Close();
            }
      

  2.   

    定义委托
    http://topic.csdn.net/u/20090730/17/86fcd2f7-40de-49ed-be09-4217f6b2f14a.html