Click here to Skip to main content
15,849,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wish to connect Form1 and Form2.
That's form1' text_Data to write Form2' textBox and Form2's text_data to write Form1's textBox.

Form1 <------> Form2
textBox1->Text ---> send textBox1-Text
textBox2-Text get <---- textBox2->Text

I don't know it's the way.
I would appreciate way if you cloud tell me how.

Please....

Thank you

What I have tried:

Form1                <------>   Form2
textBox1->Text       ---> send    textBox1-Text
textBox2-Text        get <----     textBox2->Text
Posted
Updated 7-Dec-19 20:46pm
Comments
Afzaal Ahmad Zeeshan 8-Dec-19 2:38am    
Pass the reference of the first form to the second form's constructor. This way you will be able to make changes to the member fields of the first form (use encapsulation). This is the easiest approach.

1 solution

Exactly how depends on the "relationship" between the two forms.
Have a look at these, one of them will fit your circumstances.
The form that creates an instance of another:
C#
MyForm mf = new MyForm();
mf.Show();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
The code is in C#, but it's pretty obvious and exactly the same process in C++.
 
Share this answer
 
Comments
HeeMongKorea 8-Dec-19 4:57am    
Thank you
I will try it.
And I want to result a good chance.
One more thank you again.
OriginalGriff 8-Dec-19 5:58am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900