次の方法で共有


How do I inform one form that data in another form got changed?

Abstract
This short sample demonstrates how to let one form in a Windows Forms application know when data in another form got changed. To implement this behavior I’ll show you how to create an event on Form2 and how to subscribe to this event on Form1 using the Handles keyword. The C# source code uses delegates to implement the aforementioned behavior.
NotifyAnotherForm.png

How Do I Video
The corresponding How-Do-I video can be found here.

Source Code
Visual Basic | C#

Additional Resources
Handling and Raising Events
Events in Visual Basic

Prerequisites
The examples were created using Visual Basic 2008 Express but do also apply to older versions of Visual Studio. Even though this concept is demonstrated in Windows Forms the same pattern can be used in WPF.

Enjoy!

   Daniel