Changed Events

Suppose you have bound a persistent object to controls on a Windows Form. Now your software changes an object property. The new property value should now be displayed in the control. But there must be a way to inform the control that the property has changed. In .NET this can be achieved by creating an event that follows a certain naming convention: The event must be of the same name as the property with the postfix "Changed". For the property FirstName in the class Employee from above it would look like this:

public event EventHandler FirstNameChanged;

public string FirstName

{

    get { return FirstName; }

    set

    {

        FirstName = value;

        if (FirstNameChanged != null)

            FirstNameChanged(this, EventArgs.Empty);

    }

}

If an event like that exists, the WinForms library registers itself as a listener to the event during the creation of a binding. Your code has to take care that the event is fired in case of changes. That allows the control to notice any change of the property and change its appearence according to the new value.

If you select the option Generate change events with AddAccessor in the NDO configuration dialog NDO generates the necessary code for you.