ApplicationSettingsBase.SettingsSaving Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs before values are saved to the data store.

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

public event SettingsSavingEventHandler SettingsSaving

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.

void frmSettings1_SettingsSaving(object sender, CancelEventArgs e)
    //Should check for settings changes first.
    DialogResult dr = MessageBox.Show(
                    "Save current values for application settings?",
                    "Save Settings", MessageBoxButtons.YesNo);
    if (DialogResult.No == dr)
        e.Cancel = true;

.NET Framework
Available since 2.0
Return to top