views:

38

answers:

2

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)

A: 

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.

Cory Charlton
+1  A: 

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.

AMissico
Awesome thanks.
dr. evil
Please explain the down vote. This is an accepted answer. The question is answer and a work around provided. Therefore, providing a comment would help.
AMissico