I have a number of application settings (in user scope) for my custom grid control. Most of them are color settings. I have a form where the user can customize these colors and I want to add a button for reverting to default color settings. How can I read the default settings?
For example:
CellBackgroundColor
in Properties.Settings
.CellBackgroundColor
to Color.White
using the IDE.CellBackgroundColor
to Color.Black
in my program.Properties.Settings.Default.Save()
.Restore Default Colors
button.Now, Properties.Settings.Default.CellBackgroundColor
returns Color.Black
. How do I go back to Color.White
?
@ozgur,
Settings.Default.Properties["property"].DefaultValue // initial value from config file
Example:
string foo = Settings.Default.Foo; // Foo = "Foo" by default
Settings.Default.Foo = "Boo";
Settings.Default.Save();
string modifiedValue = Settings.Default.Foo; // modifiedValue = "Boo"
string originalValue = Settings.Default.Properties["Foo"].DefaultValue as string; // originalValue = "Foo"