本帖最后由 tuyi911 于 2010-10-11 14:27:28 编辑

解决方案 »

  1.   

    F1 窗体:public partial class F1 : Form
        {
            public F1()
            {
                InitializeComponent(); 
            }
            
            //添加事件
            private void btnAdd_Click(object sender, EventArgs e)
            {
                F2 f = new F2(this);
                f.Show();
            }
    }
    F2 窗体:public partial class F2 : Form
        {
            Form f = new Form();
            public F2(Form form)   //构造函数
            {
                f = form;
                InitializeComponent();
            }         //确定时间
            private void btnConfirm_Click(object sender, EventArgs e)
            {
                ((F1)f).listBox1.Items.Add(this.textBox1.Text.Trim());  //1窗体的listbox添加      
                this.Hide();
                f.Show();
                ((F1)f).listBox1.Refresh();
                
            }
        }
      

  2.   

    窗口传值
    用委托
    子窗口调用父窗口控件
    看我博客
    http://blog.csdn.net/chazikai24/archive/2010/09/01/5855254.aspx
      

  3.   

    委托实现
    Form2 f2 = new Form2();
     private void button1_Click(object sender, EventArgs e)
      {
      f2.MyA+= new Form2.AA(B);
      f2.Show();
      }
    void B(string str){}public delegate void AA(string str);
    public event AA MyA;
     private void button1_Click(object sender, EventArgs e)
      {
      this.MyA();
      }
    父窗体:
    protected void btnEidt_Click(object sender,EventArgs arg)
    {
      if(SubForm().ShowDialog()==DialogResult.Ok)
      {
      //再次调用数据绑定代码。
      }
    }
      

  4.   

    Form1        private void button1_Click(object sender, EventArgs e)
            {
                using (Form2 frm = new Form2())
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        listBox1.Items.Add(frm.Content);
                    }
                }
            }Form2        public string Content
            {
                get { return this.textBox1.Text; }
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.DialogResult = DialogResult.OK;
            }