我的自定义网格控件有许多应用程序设置(在用户范围内)。其中大部分是颜色设置。我有一个表单,用户可以在其中自定义这些颜色,并且我想添加一个用于恢复默认颜色设置的按钮。如何读取默认设置?
例如:
- 我有一个名为的用户设置
CellBackgroundColor
in Properties.Settings
.
- 在设计时我设置了值
CellBackgroundColor
to Color.White
使用IDE。
- 用户集
CellBackgroundColor
to Color.Black
在我的程序中。
- 我保存设置
Properties.Settings.Default.Save()
.
- 用户点击
Restore Default Colors
button.
Now, Properties.Settings.Default.CellBackgroundColor
回报Color.Black
。我怎样才能回到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"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)