简体   繁体   English

使用设置不工作的复选框保存状态(winforms C#)

[英]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.是的,我确实有一些使用该设置的东西,并且可以正常工作。

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.我建议您在表单加载时抓取Properties CheckBox设置值并将其应用于CheckBox ExampleToggle 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.如果他们必须输入代码,许多人会继续前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM