<appSettings>
<add key="server" value="smtp.gmail.com" />
<add key="username" value="This email address is being protected from spambots. You need JavaScript enabled to view it." />
<add key="password" value="password" />
</appSettings>
then in the specific form's code,i added the following
lines to access those settings -
textBox1.Text = ConfigurationManager.AppSettings["server"];
textBox2.Text = ConfigurationManager.AppSettings["username"];
textBox3.Text = ConfigurationManager.AppSettings["password"];
then i added a button to update settings.when clicked
on the button the event method does that -
private void UpdateButton_Click_1(object sender, EventArgs e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["server"].Value = textBox1.Text;
config.AppSettings.Settings["username"].Value = textBox2.Text;
config.AppSettings.Settings["password"].Value = textBox3.Text;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}