Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Form1 triggers Form2 to open. Form2 has overloaded constructor which takes calling form as argument and provides its reference to Form2 members. This solves the communication problem. For example I've exposed Label Property as public in Form1 which is modified in Form2.</p> <p>With this approach you can do communication in different ways.</p> <p><strong><a href="http://demo.ruchitsurati.net/files/FormsCommunication.zip" rel="noreferrer">Download Link for Sample Project</a></strong></p> <p>//<strong>Your Form1</strong></p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 frm = new Form2(this); frm.Show(); } public string LabelText { get { return Lbl.Text; } set { Lbl.Text = value; } } } </code></pre> <p>//<strong>Your Form2</strong></p> <pre><code>public partial class Form2 : Form { public Form2() { InitializeComponent(); } private Form1 mainForm = null; public Form2(Form callingForm) { mainForm = callingForm as Form1; InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.mainForm.LabelText = txtMessage.Text; } } </code></pre> <p><a href="http://demo.ruchitsurati.net/files/frm1.png" rel="noreferrer">alt text http://demo.ruchitsurati.net/files/frm1.png</a></p> <p><a href="http://demo.ruchitsurati.net/files/frm2.png" rel="noreferrer">alt text http://demo.ruchitsurati.net/files/frm2.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload