How do I pass a value from a child back to the parent form?


Question

How do I pass a value from a child back to the parent form? I have a string that I would like to pass back to the parent.

I launched the child using:

FormOptions formOptions = new FormOptions();
formOptions.ShowDialog();
1
47
5/18/2012 10:47:49 AM

Create a property (or method) on FormOptions, say GetMyResult:

using (FormOptions formOptions = new FormOptions())
{
    formOptions.ShowDialog();

    string result = formOptions.GetMyResult;

    // do what ever with result...
}
59
1/23/2012 1:38:24 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon