C#(Winfrom)窗体传值问题(子窗体回传值给父窗体)

来源:百度知道 编辑:UC知道 时间:2024/05/26 07:14:50
情况是这样的 From1中有个窗体textbox和一个Button按钮 From2中也有一个textbox和button按钮 现在要做一个这样的事情事情 点击From1的button按钮弹出From2窗体 然后在From2的textbox中输入一串字符串 点击From2中Button按钮关闭From2窗体 并且将刚才输入的字符串在From1窗体中的Textbox中显示 最好给出源代码(先给10分,答案满意在追加15分)
一楼的朋友 能不能给出具体的代码?本人新手,不吝赐教.谢谢!~

Form1
--------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Form2ToForm1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.GetForm(this);
form.Show();
}
}
}
--------------------------------------
Form2
-----------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;