using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace WindowsApplication1
{
    public partial class Form5 : Form
    {
        private ArrayList listData3;
        //建立私有变量，该变量用以接收复窗体的共有属性数据
        public Form5()
        {
            InitializeComponent();
            //千万别放到构造函数里面，因为在主窗体修改按钮被点击后，开始执行Form5 formChild = new Form5();
            //而在Form2的实例化过程中会在构造函数中执行Form4 pareForm = (Form4)this.Owner;而这时的this.Owner是没有值的，为空引用，
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            Form4 pareForm = (Form4)this.Owner;//实例化父窗体，建立父子窗体之间联系
            this.listData3 = pareForm.ListData2;//访问父窗体的公有属性给当前子窗体的私有变量
            foreach (object o in this.listData3)//遍历后将数据显示在listBox1之中
            {
                this.listBox1.Items.Add(o);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}