Question

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)

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top