'Checkbox save state using settings not working (winforms C#)

As you can see below, save code. No errors at all.

Image

But when I change the state of the checkbox and close the form, the setting does not update and remains false.

Yes I do have something that uses the setting, and that works normally.



Solution 1:[1]

I am not following what the problem is. How are you “checking” if the setting is saved? In other words, I see nothing in your current code that actually USES the setting. I suggest you grab and apply the Properties CheckBox setting value to the CheckBox ExampleToggle when the form loads. Something like…

private void Form1_Load(object sender, EventArgs e) {
  ExampleToggle.Checked = Properties.Settings.Default.CheckBox;
}

Also, in the future, posting pictures of code is frowned upon. You are forcing others who may help you into typing the code themselves. Many will just move on if they have to type the code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JohnG