2010-05-02 52 views
-2
private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
    { 
     Properties.Settings.Default.Save(); 
    } 

我使用的應用程序設置和當 形式負載我看到在控制 值,但我不能使用其當窗體加載 事件。如何在應用程序設置加載中使用值?

如何使用綁定的值 應用程序設置何時發生 Form1_Load?

+5

你的問題不清楚。請詳細說明。 – Ikaso 2010-05-02 04:30:43

回答

1

進入Settings

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

要保存設置

 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"); 

我希望我理解你的問題的權利,這可以幫助你。

相關問題