title: VB.NET get default value from My.Settings
body: <p>VB2010. I understand how to save settings and load them from the My.Settings namespace. What I am trying to figure out is how to get the default value of a settings and present it to the user. I don't want to save the setting I just want to show what the current value is and what the default value is. I tried this but I don't think it does what I think it's supposed to do:</p>
  
  <pre><code> Msgbox "Current setting: " &amp; My.Settings.CustLineWidth &amp; vbcrlf &amp; _
          "Default setting: " &amp; My.MySettings.Default.CustLineWidth
  </code></pre>
  
  <p>The default as I have setup in the IDE is 10 but the user changed it to 25. If I run the above code I get</p>
  
  <pre><code> Current setting: 25
   Default setting: 25
  </code></pre>
  
  <p>What I would like is</p>
  
  <pre><code> Current setting: 25
   Default setting: 10
  </code></pre>
  
  <p>Solution: I iterate through all the settings and print out the current value and the default value like this</p>
  
  <pre><code>        For Each prop As Configuration.SettingsPropertyValue In My.Settings.PropertyValues
              Debug.Print("Name={0}", prop.Name)
              Debug.Print("  Value  ={0}", prop.PropertyValue.ToString)
              Debug.Print("  Default={0}", prop.Property.DefaultValue.ToString)
          Next prop
  </code></pre>