Use this pattern:
class ParentForm : Form
{
private ShowChildForm()
{
ChildForm child = new ChildForm();
child.ShowDialog();
int interestingValue = child.InterestingValue;
child.Dispose();
}
}
class ChildForm : Form
{
public int InterestingValue { get; private set }
}
No touching the parent form from child side. Child should not need to know anything about its parent. Just get instantiated, do what it is supposed to do (like setting its
InterestingValue) and die in peace.
Meanwhile, the parent has to know about its child. It's the
ParentForm that created the child, after all. So the parent is not harmed too much with the need to know what value it requests from its child.