Hello. I am working on a GUI that has two forms (Form1 & child). I have two global variables on the forms to use to pass data between them. When a button is clicked on Form1, child pops up and data is passed to its global variable. When a button is clicked on child, I want to pass some data back to Form1. How do I do that?
Ex.
Form1:
Form2 child = new Form2();
public string imagePath;
private void btn_Click(object sneder, EventArgs e)
{
child.path = imagePath;
}
child:
public string path;
private void btn_Click(object sneder, EventArgs e)
{
(Form1 global variable) = path;
}
How do I correct the method in the child form?
Passing data from child form to parent form C#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Tanmay SarkarRank #1,407 · 1.2K reputationPosted Aug 1, 2010, 9:40 AM EDT
I upload a file for your help.
Here A value will send from parent to his child & also a value will send child to his parent.
Note that the parent's textbox modifier is Internal.
Hope it help you!
Thank you!
Please mark it as an answer if it help you!
Sam HobbsRank #107 · 20.5K reputationPosted Aug 2, 2010, 9:46 AM EDT
All of that is a bit more complicated than it needs to be becasue you have "Form2 child" as a member of the form1 class. If you make "Form2 child" as local to the click event in form1, then it would be easier.