Resetting a key in My.Setting
I know it's possible to reset the My.Settings
with Reset()
method.
Is there anyway to do the same thing for just one setting? Or simple getting its def开发者_如何学运维ault value instead of the one changed by user. (I'm referring to User Scope Settings)
You cannot reset one setting. It is easy to get the default value through the Properties
collection. Specifically, the SettingsProperty
's DefaultValue
property. Moreover, the PropertyValues
collection contains SettingsPropertyValue
objects that allow you to determine if a property/setting has changed through the IsDirty
or UsingDefaultValue
properties.
Dim a As Object = My.Settings.Properties.Item("fred").DefaultValue
Dim b As Boolean = My.Settings.PropertyValues.Item("fred").IsDirty
Dim c As Boolean = My.Settings.PropertyValues.Item("fred").UsingDefaultValue
I wish there was a way to get these values without having to specify the name of the setting.
Not sure about resetting just one setting but you could copy the settings to another object, Reset()
and then copy back all the settings values except the one you wanted to reset.
精彩评论