private void checkedListBoxOperator_ItemCheck(object sender, ItemCheckEventArgs e) { OperatorCheckedList.Clear(); foreach (var item in checkedListBoxOperator.CheckedItems) { OperatorCheckedList.Add(item as Operator); } if (e.NewValue == CheckState.Unchecked) { OperatorCheckedList.Remove(checkedListBoxOperator.Items[e.Index] as Operator); } else { OperatorCheckedList.Add(checkedListBoxOperator.Items[e.Index] as Operator); } if (isNotUpdateOperatorAll) { return; } bool isAllChecked = checkedListBoxOperator.Items.Count == OperatorCheckedList.Count(); RefreshCodeCheckedBox(); textBoxOperator.Text = isAllChecked ? "Все" : String.Join(";", OperatorCheckedList.Select(x => x.Title)); }
private void RefreshOperatorCheckedBox() { checkedListBoxOperator.Items.Clear(); OperatorCheckedList.Clear(); var operatorList = Operator.GetAllByRegionList(RegionCheckedList); checkedListBoxOperator.Items.AddRange(operatorList.ToArray()); }
private void checkBoxOperatorAll_CheckedChanged(object sender, EventArgs e) { isNotUpdateOperatorAll = true; OperatorCheckedList.Clear(); if (checkBoxOperatorAll.Checked) { foreach (var item in checkedListBoxOperator.Items) { OperatorCheckedList.Add(item as Operator); } } SetItemChecked(this.checkedListBoxOperator, this.checkBoxOperatorAll.Checked, ref this.isNotUpdateOperatorAll); this.textBoxOperator.Text = "Все"; }