ApplicationSettingsBase.SettingChanging Event

Definition

Occurs before the value of an application settings property is changed.

C#
public event System.Configuration.SettingChangingEventHandler SettingChanging;

Event Type

Examples

The following code example shows the SettingChanging event handler for object of type FormSettings, which is a wrapper class derived from ApplicationSettingsBase. The handler displays the event information in a textbox named tbStatus. The full code example is listed in the ApplicationSettingsBase class overview.

C#
void frmSettings1_SettingChanging(object sender, SettingChangingEventArgs e)
{
    tbStatus.Text = e.SettingName + ": " + e.NewValue;
}

Remarks

The SettingChanging event occurs before an application setting value property is changed through the Item[] method. This event is not raised when the Reload or Reset methods are called. SettingChanging can be canceled through the SettingChangingEventArgs event data class.

You typically use the SettingChanging event to handle immediate validation of an individual settings property. For more information about validation, see How to: Validate Application Settings.

There is no corresponding SettingChanged event for this class; instead, see the PropertyChanged event.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also