Hi,
I am trying to use a checkListBox to select one of three options. I only want any one option at a time.
I have found the following 2 instructions, which, I would have thought, would have done what I want, but I can still check all three boxes.
this.checkedListBox1.CheckOnClick = true; this.checkedListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One;Incidentally, I tried
this.checkedListBox1.CheckOnClick = true;
this.checkedListBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
and this did whatI expected, I could not check any of the boxes.
So, any one know what I am doing wrong
Many thanks for being there
John.

How do I limit ticks is a checkListBox to one at a time?
Mervin Lobo
Heng-yi Liu
Tarek Ghazali
Helio Gama Faria Filho
Hi PJ
Thanks for your reply. I will try the Radio buttons, but out of curiosity, it will also have a go with your code. there are somethings in it which I haven't seen before and I could probably use in the future.
Many thanks
John
Cormac Redmond
Hi boban,
Many thanks for your advice, I will give it a try!
John
Burrough
You can iterate over all the controls on the container and uncheck all boxes that are needed. You can use the method posted below for every checkbox. Just paste this code in your form and wire all checkboxes to it. Here is the example:
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
CheckBox sender = sender as CheckBox;
if (sender != null && sender.Checked)
{
foreach (Control control in this.Controls)
{
if (control is CheckBox && control != sender)
{
((CheckBox)control).Checked = false;
}
}
}
}
But I agree with Boban.s, you should use RadioButtons instead.
Pavan Apuroop
Hi,
Thanks for the information. I could have been struggling for ages trying to sort out the groupbox issue.
Many thanks
John