I would like to only have single checkbox selected at a time. My program reads from a textfile and creates checkboxes according to how many \"answers\" there are in the text
Try using an external Bool variable to know when the CheckBox was changed "automatically"
CheckBox checkBox1;
CheckBox checkBox2;
Bool changed = false; //This one
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (!changed)
{
if (checkBox2.Checked)
{
changed = true;
checkBox2.Checked = false;
}
}
else
{
changed = false;
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (!changed)
{
if (checkBox1.Checked)
{
changed = true;
checkBox1.Checked = false;
}
}
else
{
changed = false;
}
}