private void InitListBox() { if (this.CurrentRole != null) { if (checkedListBoxControl1.Items.Count == 0) { foreach (Privilege pg in Privilege.GetAllPrivileges()) { checkedListBoxControl1.Items.Add(pg, false); } } checkedListBoxControl1.BeginUpdate(); List <Impower> myFunctions = Impower.GetRoleImpowers(this.CurrentRole.Name); foreach (CheckedListBoxItem item in checkedListBoxControl1.Items) { Privilege privilege = (Privilege)item.Value; bool isChecked = myFunctions.Find(a => a.Privilege == privilege) != null; item.CheckState = isChecked ? CheckState.Checked : CheckState.Unchecked; } checkedListBoxControl1.EndUpdate(); } }