VB2010. I am trying to create one routine that will load all settings into a form with maybe like 50 controls. The first case it load all the user defined settings. The second case loads all the app default settings. I recently found that my routine below will not work as both setting classes are the same.
Private Sub LoadSettingsIntoControls(stsType As Integer)
Dim stsClass As My.MySettings
Select Case stsType
Case 0 ' user-defined
stsClass = My.Settings
Case 1 'app default
stsClass = My.MySettings.Default 'this is the same as My.Settings
Case Else
Throw New Exception("Invalid settings type.")
End Select
txtTmpDir.Text = stsClass.TempDir
txtDataPath.Text = stsClass.DataPath
'<about 50 more controls>
End Sub
I also found that to get the app default value for a setting I need something like
My.Settings.PropertyValues("TempDir").Property.DefaultValue
I've been trying to wrap up both the user-defined and app default settings into one routine but haven't been able to do so. What I would like is something that needs little upkeep in case I change the setting variable names. I've been looking at documentation and samples but haven't found anything solid. Any suggestions?