views:

63

answers:

1
    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        Properties.Settings.Default.Save();
    }

I used Application Settings and When Form was load i see value in control but i can't use its when Form load event.

how to use value that bind from Application Settings when event Form1_Load ?

A: 

To access settings

string a=ConfigurationManager.AppSettings["someProperty"];

To save settings

        ExeConfigurationFileMap map=new ExeConfigurationFileMap();
        map.ExeConfigFilename=pathToYourConfigurationFile; //<-String
        Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map,ConfigurationUserLevel.None);
        config.AppSettings.Settings["someProperty"].Value = a;
        config.Save(ConfigurationSaveMode.Full);
        ConfigurationManager.RefreshSection("appSettings"); 

I hope I understood your question right and this helps you.

m0s