using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private bool hasChanged; private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (!hasChanged) hasChanged = true; else return; if (((CheckBox)sender).Name.EndsWith("1")) { checkBox2.Checked = !checkBox2.Checked; if (checkBox2.Checked) checkBox2.Enabled = false; else checkBox2.Enabled = true; checkBox3.Checked = !checkBox3.Checked; if (checkBox3.Checked) checkBox3.Enabled = false; else checkBox3.Enabled = true; if (checkBox1.Checked) checkBox1.Enabled = false; hasChanged = false; } else if (((CheckBox)sender).Name.EndsWith("2")) { checkBox3.Checked = !checkBox3.Checked; if (checkBox3.Checked) checkBox3.Enabled = false; else checkBox3.Enabled = true; checkBox4.Checked = !checkBox4.Checked; if (checkBox4.Checked) checkBox4.Enabled = false; else checkBox4.Enabled = true; if (checkBox2.Checked) checkBox2.Enabled = false; hasChanged = false; } else if (((CheckBox)sender).Name.EndsWith("3")) { checkBox4.Checked = !checkBox4.Checked; if (checkBox4.Checked) checkBox4.Enabled = false; else checkBox4.Enabled = true; checkBox5.Checked = !checkBox5.Checked; if (checkBox5.Checked) checkBox5.Enabled = false; else checkBox5.Enabled = true; if (checkBox3.Checked) checkBox3.Enabled = false; hasChanged = false; } else if (((CheckBox)sender).Name.EndsWith("4")) { checkBox5.Checked = !checkBox5.Checked; if (checkBox5.Checked) checkBox5.Enabled = false; else checkBox5.Enabled = true; //// checkBox1.Checked = !checkBox1.Checked; if (checkBox1.Checked) checkBox1.Enabled = false; else checkBox1.Enabled = true; /// if (checkBox4.Checked) checkBox4.Enabled = false; hasChanged = false; } /// else { checkBox1.Checked = !checkBox1.Checked; if (checkBox1.Checked) checkBox1.Enabled = false; else checkBox1.Enabled = true; checkBox2.Checked = !checkBox2.Checked; if (checkBox2.Checked) checkBox2.Enabled = false; else checkBox2.Enabled = true; if (checkBox5.Checked) checkBox5.Enabled = false; hasChanged = false; } /// } } }