我的代码遇到了一些问题,该代码应该重做用户在设置中所做的更改。当我在关闭表单后单击“否”时,它ribbonBar2
消失了,但是当我打开设置时,该复选框仍然被选中,尽管它不应该被选中。为什么?
Form1 frm1;
public Form8(Form1 frm1): this()
{
this.frm1 = frm1;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
frm1.ribbonBar2.Visible = checkBox1.Checked;
}
private void form8_closing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.checkBox1 = checkBox1.Checked;
DialogResult result1 = MessageBox.Show("Do you want to Save your Settings?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result1 == DialogResult.Yes)
{
Properties.Settings.Default.Save();
}
if (result1 == DialogResult.No)
{
checkBox1.Checked = !Properties.Settings.Default.checkBox1;
}
e.Cancel = false;
}