30 January 2014

Pass the text box value from one form to another form label

//form1:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        Form2 f2 = new Form2(textBox1.Text);
        f2.Show();
    }
}
//form2:
public partial class Form2 : Form
{
    public Form2(string value)
    {
        InitializeComponent();
        label2.Text = value;
    }
}

No comments:

Post a Comment