passing data from child form to parent form C#
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?