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