Passing data between WinForms forms [duplicate]

If you need to know about the changed value before closing the child form, a custom event will let you inform the parent form elegantly.

Here’s a great tutorial on delegates and events in C#

http://www.akadia.com/services/dotnet_delegates_and_events.html

Once the child form is instantiated, the parent form would register to receive one or more custom events (as needed) from the child.

Another methodology is to pass a reference to the parent form into the child form so that the child can invoke a function or property of the parent to inform about the change. However, that approach creates a tight coupling between the two forms and is discouraged.

Leave a Comment