dr. evil
dr. evil

Reputation: 27265

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 default value instead of the one changed by user. (I'm referring to User Scope Settings)

Upvotes: 2

Views: 412

Answers (2)

AMissico
AMissico

Reputation: 21684

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.

Upvotes: 4

Cory Charlton
Cory Charlton

Reputation: 8938

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.

Upvotes: 0

Related Questions