public static void SetItemsChecked(System.Windows.Forms.CheckedListBox checkedlistbox, bool check) { if (checkedlistbox == null) { throw new System.ArgumentNullException("checkedlistbox"); } foreach (int index in System.Linq.Enumerable.Range(0, checkedlistbox.Items.Count)) { checkedlistbox.SetItemChecked(index, check); } }
/// <summary> /// Method to check or uncheck all checklistbox (users) /// </summary> /// <param name="Selected"></param> /// <param name="checkedListBox"></param> private void SelectDeselectAll(bool Selected, System.Windows.Forms.CheckedListBox checkedListBox) { for (int i = 0; i < checkedListBox.Items.Count; i++) // loop to set all items checked or unchecked { checkedListBox.SetItemChecked(i, Selected); } }