点击button1弹出form2,并在form2中点击button2来调用form1的方法

 
1.     private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.f1 = this;//把当前的Form1给form2中的form1对象
            f2.Show();
 
        }
 
2.
   public partial class Form2 : Form
    {
        public Form1 f1 = new Form1();
        public Form2()
        {
            InitializeComponent();
        }
 
        private void Form2_Load(object sender, EventArgs e)
        {
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            f1.addname(textBox1.Text.Trim());
        }
    }
posted @ 2016-12-09 20:44  流星~泪雨  阅读(642)  评论(0编辑  收藏  举报