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;
}

posted @ 2021-08-26 20:53  .net&new  阅读(240)  评论(0编辑  收藏  举报