您可以使用表单级别标志来保持加载初始数据的状态
bool flag = false;
保存check1_State
并且check2_State
仅当上面的标志是true
在表单加载事件中,从属性加载数据后设置标志
checkBox1.Checked = Properties.Settings.Default.check1_State;
checkBox2.Checked = Properties.Settings.Default.check2_State;
flag = true;
样本 :
public partial class Form1 : Form
{
bool flag = false;
public Form1()
{
InitializeComponent();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (flag)
{
//save settings
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (flag)
{
//save settings
}
}
private void Form1_Load(object sender, EventArgs e)
{
checkBox1.Checked = Properties.Settings.Default.check1_State;
checkBox2.Checked = Properties.Settings.Default.check2_State;
flag = true;
}
}