【发布时间】:2017-03-27 00:28:30
【问题描述】:
我正在尝试在我的 UserControl3 上保存复选框的状态。怎么能做到呢?在这我试图通过计时器保存它们。然后在 UserControl3_Load 上添加他们的保存。
private void UserControl3_Load(object sender, EventArgs e)
{
materialCheckBox1.Checked = Properties.Settings.Default.CheckBox1;
materialCheckBox2.Checked = Properties.Settings.Default.CheckBox2;
materialCheckBox4.Checked = Properties.Settings.Default.CheckBox3;
}
private void timer1_Tick(object sender, EventArgs e)
{
Properties.Settings.Default.CheckBox1 = materialCheckBox1.Checked;
Properties.Settings.Default.CheckBox2 = materialCheckBox2.Checked;
Properties.Settings.Default.CheckBox3 = materialCheckBox4.Checked;
Properties.Settings.Default.Save();
}
【问题讨论】:
-
1.使用
CheckChanged/FormClosing事件而不是计时器 2。你的问题是什么? -
UserControl 中没有 FormClosing/CheckChanged 事件。问题是它没有保存。
-
设置的范围是什么?
-
当您选择
(ApplicationSettings)下CheckBox的Checked属性时,您创建的设置属性为bool类型。