private void checkedListBoxRegion_ItemCheck(object sender, ItemCheckEventArgs e) { RegionCheckedList.Clear(); foreach (var item in checkedListBoxRegion.CheckedItems) { RegionCheckedList.Add(item as Region); } if (e.NewValue == CheckState.Unchecked) { RegionCheckedList.Remove(checkedListBoxRegion.Items[e.Index] as Region); } else { RegionCheckedList.Add(checkedListBoxRegion.Items[e.Index] as Region); } if (isNotUpdateRegionAll) { return; } RefreshOperatorCheckedBox(); bool isAllChecked = checkedListBoxRegion.Items.Count == RegionCheckedList.Count(); textBoxRegion.Text = isAllChecked ? "Все" : String.Join(";", RegionCheckedList.Select(x => x.Title)); }
private void checkBoxRegionAll_CheckedChanged(object sender, EventArgs e) { isNotUpdateRegionAll = true; RegionCheckedList.Clear(); if (checkBoxRegionAll.Checked) { foreach (var item in checkedListBoxRegion.Items) { RegionCheckedList.Add(item as Region); } } SetItemChecked(this.checkedListBoxRegion, this.checkBoxRegionAll.Checked, ref this.isNotUpdateRegionAll); this.textBoxRegion.Text = "Все"; }