January 1, 2009

Access Settings/Resource in c#

Settings take the following form:
// eg. When the setting is a string
$AppNamespace$.Properties.Settings.Default.$PropertyName$ = "somechange"; 
$AppNamespace$.Properties.Settings.Default.Save();
OR
// see the Settings.Designer.cs file for the namespace
using $SomeNamespace$.Properties$
...
// eg. When the setting is a string
Settings.Default.$PropertyName$ = "somechange"; 
Settings.Default.Save();

// to use
myTextBox.Text = Settings.Default.$PropertyName$
Can only save "User Settings" and they do not get saved to the local config file but to: $Drive$:\Documents and Settings\$UserAccount$\Local Settings\Application Data\$ApplicationName$\...

To Access a Resource from a ".resx" file:

var $VariableName$ = Properties.Resources.$ResourceName$

No comments: