Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CheckedListBox allowing only one item to be checked

In my CheckedListBox app I want to allow only a single item to be checked.

I have these properties already set

checkOnClick = true;
SelectionMode = One;

Any advise will be appreciated

like image 862
Ahmed Avatar asked May 11 '12 14:05

Ahmed


1 Answers

uncheck all other items in ItemCheck event as below :

private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
      for (int ix = 0; ix < checkedListBox1.Items.Count; ++ix)
        if (ix != e.Index) checkedListBox1.SetItemChecked(ix, false);
    }
like image 129
Zaki Avatar answered Oct 13 '22 01:10

Zaki