form_parent 中有panel2  ,  其中放置form_child。点击form_parent 中的button1之后,执行
{
……
form_child child =new form_child(string para1);
……
child.show();
}
此处能正常运行,但是到第二次想给child传递新参数的时候重新执行此代码无效。
测试过在form_child中执行this.close():之后可以实现。
但是不知有什么方法可以在form_parent 中执行child.close();
注:form_child 实例化必须在button1的点击事件后,因为要判断参数是否正确。
谢谢!

解决方案 »

  1.   


      private Form2 fp = null;
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                Form2 f = new Form2();
                fp = f;
                f.Show();
            }        private void button2_Click(object sender, EventArgs e)
            {
                fp.Close();
            }
      

  2.   

    LZ要动态获取主窗体的Panel...??????需要在主窗体建一个公共方法]
    Pubile panel GetPanel()
    {
      return thsi.panel2;
    }在字窗体中。。
    Panel p2=父窗体.GetPanel();//当然要把父窗体参数传递到子窗体。。
      

  3.   

    问题解决了,是在 子窗体中加入 public setpara(……) 过程,直接从 父窗体中调用child.setpara(……)即可。谢谢大家!
    http://zhidao.baidu.com/question/238951105.html?fr=im100009