其他分享
首页 > 其他分享> > winform窗体之间传递参数

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

标签:InitializeComponent,form,text,private,Form2,参数,窗体,public,winform
来源: https://www.cnblogs.com/wugh8726254/p/15191476.html