There are sevral ways you can send complex information from child. If you use modal mode you can always loog into child while variable is stil accsessible.
if (true)
{
ChildForm frm = new ChildForm();
frm.ShowDialog(this); // Modal accsess
MessageBox.Show(frm.StringToGet();
}
// MessageBox.Show(frm.StringToGet(); // This is outside scope of frm. Here form no longer exsist
You can use static class, so that class does not need to be intilaized and can be accsessd from any Form.
public static class staticClass
{
static staticClass() // static class constructior
{
SomeText = "Intalized in constructior";
}
static ~staticClass(){} // destructor of static class
public static String SomeText;
}
// parentForm
if (true)
{
MessageBox.Show(staticClass.SomeText); // returns Intalized in constructior
ChildForm.ShowDialog();
MessageBox.Show(staticClass.SomeText); // returns other string that was changed in child form
}
And the third option is to pass a reference to a class or to a variable. This one is the most complex. But the static class should be the best option if first option is not enough.