1、通过在别的窗体定义static变量 实现传值
private void button1_Click(object sender, EventArgs e) { //打开窗体 要打开的窗体 fr = new 要打开的窗体(); fr.ShowDialog(); } private void button2_Click(object sender, EventArgs e) { //接收打开的值并显示到自己的窗体中 this.textBox1.Text = 要打开的窗体.strRes; }
public static string strRes = ""; private void button1_Click_1(object sender, EventArgs e) { //获取自己窗体的值 string str = this.textBox1.Text; //将值付给静态变量 strRes = str; }