winform窗体之间传递参数

1:参数的传递
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Hide(); Form2 form = new Form2(textBox1.Text); form.ShowDialog(); Show(); } }

2:获取传递的参数

public Form2()
{
InitializeComponent();
}
public Form2(string text)
{
InitializeComponent();
this.text = text;
}
private void Form2_Load(object sender, EventArgs e)
{
label1.Text = "Hello, world!" + text;
}

上一篇:winform 子窗体调用主窗体的方法


下一篇:C#窗体间互相传值