lundi 4 juillet 2016

CheckedListBox Select All Items - Windows Forms C#

I have a checkbox that when checked checks all itens in a checkedListBox. When the checkbox goes unchecked it should uncheck all itens in the list.

Code:

 if (checkBoxCheckAllPrivileges.Checked)
            for (int i = 0; i < checkedListBoxUsersWhoSee.Items.Count; i++)
                checkedListBoxUsersWhoSee.SetItemChecked(i, true);
 else
            for (int i = 0; i < listBoxUsers.Items.Count; i++)
                checkedListBoxUsersWhoSee.SetItemChecked(i, false);

Is the problem in this code? Does the .SetitemChecked work giving it the parameter as false? Is there any other way to uncheck the items?




Aucun commentaire:

Enregistrer un commentaire