uhm what is the type of Settings?
Anyway I think you missed .Context ..try to write:
Settings.Default.Context["myKey"].ToString()
The problem is that the value is an User-Scope setting and persists only for the duration of the application session. I think you need application-scope settings which can only be changed at design time ( in the Project Properties -> Settings tab ) or by altering the .exe.config file in between application sessions ( http://msdn.microsoft.com/en-us/library/bb397744.aspx )
You have to do something like this:
using System.Configuration;
namespace WindowsFormsApplication1
{
class MySettings : ApplicationSettingsBase
{
[UserScopedSetting]
public string SavedString
{
get { return ( string )this["SavedString"]; }
set { this["SavedString"] = value; }
}
}
public partial class Form1 : Form
{
MySettings m_Settings;
public Form1()
{
InitializeComponent();
}
private void Form1_Load( object sender, EventArgs e )
{
m_Settings = new MySettings();
Binding b = new Binding( "Text", m_Settings, "SavedString", true, DataSourceUpdateMode.OnPropertyChanged );
this.DataBindings.Add( b );
}
private void Form1_FormClosing( object sender, FormClosingEventArgs e )
{
m_Settings.Save();
}
private void button1_Click( object sender, EventArgs e )
{
this.Text = "My Text";
}
}
}
This application creates a Form with no caption and a button in the center.
Once clicked on the button the .Text ( so the caption ) changes and it's saved when closing the form.
Rerun the application and you will have it with the new caption My Text :)
If you need the complete source code just tell me :)