You do:
//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();
textBox1.Text = value;
}
}
Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
If you want to pass the value from form1 to form2 when the form2 is opened, you can use this kind of code:
//form1:
public partial class Form1 : Form
{
Form2 f2;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (f2 == null)
f2 = new Form2();
f2.ValueFromForm1(textBox1.Text);
f2.Show();
}
}
//form2:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public void ValueFromForm1(string value)
{
textBox1.Text = value;
}
}
Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
Plz, make this thread has solved if u find ur answer.
Saikalyankumar
Junior Poster in Training
91 posts since Mar 2011
Reputation Points: 8
Solved Threads: 23
Man, again and again. One question for 2 weeks now. Please get some books and start learing by your self. We cannot teach you all here. We are here to help, not to teach ppl.
I wont answer on these kind of threads any longer. I think I gave given you more then enough, and if you still havent figured it out by now, this is not my problem. Sorry for sounding a bit harsh, but I simply dont like the way you are "forcing" us to do all the code you need instead of you.
bye
Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474