日期:2014-05-17 浏览次数:20916 次
namespace 在窗体间传值
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2=new Form2();
f2.Fangfa = UpdateTextBox1;
f2.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void UpdateTextBox1(string txt)
{
this.textBox1.Text = txt;
}
}
}
namespace 在窗体间传值
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public WeiTuoDelegate Fangfa;
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
this.Text = textBox1.Text;
//获取用户输入的值
string userInput = textBox1.Text;
//更新窗口1textbox1文本的方法
Fangfa(userInput);