Click to See Complete Forum and Search --> : use of ApplicationSettingsBase


wmestdagh
February 10th, 2005, 07:50 AM
Hi,

I'm trying a class with ApplicationSettingsBase, but id does not save anything nor load. Can someone advice what is wrong here ? After the 'save' I expect somewhere to find a config file, but no nothing find...

partial class Form1: Form
{
MySettings cfg = new MySettings();

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(cfg.MyValue.ToString());
listBox1.Items.Add(cfg.MyFormColor.ToString());
cfg.MyValue = 567;
cfg.MyFormColor = System.Drawing.Color.Bisque;
}

private void button2_Click(object sender, EventArgs e)
{
//cfg.Upgrade();
cfg.Save();
}
}

public class MySettings: ApplicationSettingsBase
{
//[UserScopedSetting]
[ApplicationScopedSetting]
[DefaultSettingValue("123")]
public int MyValue
{
get { return (int)this["MyValue"]; }
set { this["MyValue"] = value; }
}

//[UserScopedSetting]
[ApplicationScopedSetting]
[DefaultSettingValue("Blue")]
public Color MyFormColor
{
get { return (Color)this["MyFormColor"]; }
set { this["MyFormColor"] = value; }
}
}