BoldDeskPremium customer service software with affordable pricing: $10 for 3 agents. Try it for free.
private MainForm mainForm;
public void StoreSender(MainForm form)
{
this.mainForm = form;
}
private void button1_Click(object sender, System.EventArgs e)
{
Form2 f = new Form2();
f.StoreSender((MainForm)this);
f.Show();
}
Now you could access the controls on the mainForm in the button_click event as follows:
private void button2_Click(object sender, System.EventArgs e)
{
this.mainForm.textBox1.Text=this.textBox2.Text;
}
I have attached a sample which illustrates this completely. Please let me know if this meets your requirements.
Regards,
Mano
Test_1.zip
>private MainForm mainForm;
>public void StoreSender(MainForm form)
>{
> this.mainForm = form;
>}
>
>private void button1_Click(object sender, System.EventArgs e)
>{
> Form2 f = new Form2();
> f.StoreSender((MainForm)this);
> f.Show();
>}
>
>Now you could access the controls on the mainForm in the button_click event as follows:
>
>private void button2_Click(object sender, System.EventArgs e)
>{
> this.mainForm.textBox1.Text=this.textBox2.Text;
>}
>
>
>I have attached a sample which illustrates this completely. Please let me know if this meets your requirements.
>
>Regards,
>Mano
>
>Test_1.zip
>