class form1{
int value = 0;
form2 form = new form2();
form.show();
value = form.returnValue;
}class form2{
public int returnValue = 0;
}
int value = 0;
form2 form = new form2();
form.show();
value = form.returnValue;
}class form2{
public int returnValue = 0;
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.FormClosing +=new FormClosingEventHandler(frm_FormClosing);
frm.ShowDialog(this);
} private void frm_FormClosing(object sender, FormClosingEventArgs e)
{
this.textBox1.Text = ((Form2)sender).ReturnValue;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} public string ReturnValue
{
get
{
return this.textBox1.Text;
}
} private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
http://blog.csdn.net/zhzuo/archive/2004/04/05/22027.aspx
http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx#sec5
2.在Form2的button1控件的Click事件输入如下代码
Form1 form =new Form1();
form.textbox1.Text = this.textbox1.Text;
this.Close;