WindowsFormsApplicationBase.SaveMySettingsOnExit Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the application saves the user settings on exit.
public:
property bool SaveMySettingsOnExit { bool get(); void set(bool value); };
public bool SaveMySettingsOnExit { get; set; }
member this.SaveMySettingsOnExit : bool with get, set
Public Property SaveMySettingsOnExit As Boolean
Property Value
True to indicate that the application saves the user settings on exit. Otherwise, False to indicate the settings are not implicitly saved.
Examples
This example has two parts.
The
InitializeSaveMySettingsOnExitsubroutine, which initializes the checked state of a CheckBox control to the current value of theSaveMySettingsOnExitproperty.The
SaveMySettingsOnExit_CheckedChangedsubroutine, which handles changes to a CheckBox control to update theMy.Application.SaveMySettingsOnExitproperty.
Private Sub InitializeSaveMySettingsOnExit()
SaveMySettingsOnExit.Checked =
My.Application.SaveMySettingsOnExit
End Sub
Private Sub SaveMySettingsOnExit_CheckedChanged(
sender As System.Object,
e As System.EventArgs
) Handles SaveMySettingsOnExit.CheckedChanged
My.Application.SaveMySettingsOnExit =
SaveMySettingsOnExit.Checked
End Sub
For this example to work, your application must have a CheckBox control named SaveMySettingsOnExit.
Remarks
The SaveMySettingsOnExit property allows the user to change how the application saves settings, at run time. You can explicitly save setting changes by using the Save method of the My.Settings object. For more information about changing and saving settings, see Application Properties.
The changes to this property are not persisted when the application closes. To change the SaveMySettingsOnExit property permanently, you must change the setting in the Project Designer:
To change the setting in the Project Designer:
- Have a project selected in Solution Explorer. Click Properties on the Project menu.
- Click the Application tab.
- Select Save My.Settings on Shutdown.|
Availability by Project Type
| Project type | Available |
|---|---|
| Windows Forms Application | Yes |
| Class Library | No |
| Console Application | No |
| Windows Forms Control Library | No |
| Web Control Library | No |
| Windows Service | No |
| Web Site | No |