I'm trying to save a List<T> into the settingsfile of my project.
I've edited the settings.settings file and added
<Setting Name="CustomTabs" Type="System.Collections.Generic.List<CustomTabItem>" Scope="User">
<Value Profile="(Default)" />
</Setting>
and edited the settings.designer.cs too
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public global::System.Collections.Generic.List<CustomTabItem> CustomTabs {
get {
return ((global::System.Collections.Generic.List<CustomTabItem>)(this["CustomTabs"]));
}
set {
this["CustomTabs"] = value;
}
}
So the Listtype is available in the settings-gui.
Now if I make Properties.Settings.Default.CustomTabs.Add(tab); The list gets filled, however if I call Save(); and restart the App, the list ist empty again.
Am I missing something to make it work? I'm using Visual Studio 2015.
You don't have to change the settings.settings fileTry removing the setting
from the settings.settings file
Also, remember to read back the stored "CustomTabs" settings value during application startup.
EDIT:2 No harm even if settings.settings file is changed like below:
The sample application is still able to retrieve the previous data during next application start up.
EDIT: I made a sample application:
Added below setting manually in settings.Designer.cs
My data class
button-1: stores the data
button-2: retrieves the data even during next application run