Add the following method to your class and within CheckedChanged
event call this method with control name and control state (Checked/Unchecked).
Updating the Configuration file
private void UpdateConfiguration(string controlName, bool checkboxState)
{
//Open Configuration file for modification
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//Get the string representation(True/False) of the checkbox state
string controlState = checkboxState ? Boolean.TrueString : Boolean.FalseString;
//Set value for control (ex:CheckBox1) under AppSettings section of configuration file
configuration.AppSettings.Settings[controlName].Value = controlState;
//Save only the modified section
configuration.Save(ConfigurationSaveMode.Modified);
//Referesh the configuration file
ConfigurationManager.RefreshSection("appSettings");
}
Calling UpdateConfiguration method
UpdateConfiguration("CheckBox1", CheckBox1.Checked);