ApplicationSettingsBase::SettingsSaving Event

 

Occurs before values are saved to the data store.

Namespace:   System.Configuration
Assembly:  System (in System.dll)

public:
event SettingsSavingEventHandler^ SettingsSaving {
	void add(SettingsSavingEventHandler^ value);
	void remove(SettingsSavingEventHandler^ value);
}

The SettingsSaving event is raised by the Save method before it stores the application settings properties to their associated data store. The associated event handler can cancel this event.

The following code example shows the SettingsSaving event handler for object of type FormSettings, which is a wrapper class derived from ApplicationSettingsBase. The handler queries the user to save the current application settings property values. The full code example is listed in the ApplicationSettingsBase class overview.

private:
    void FormSettings_SettingsSaving(Object^ sender,
        CancelEventArgs^ e)
    {
        //Should check for settings changes first.
        ::DialogResult^ dialogResult = MessageBox::Show(
            "Save current values for application settings?",
            "Save Settings", MessageBoxButtons::YesNo);
        if (::DialogResult::No == dialogResult)
        {
            e->Cancel = true;
        }
    }

.NET Framework
Available since 2.0
Return to top
Show: