public FlagCheckedListBoxItem Add(int v, string c) { FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c); Items.Add(item); return(item); }
protected void UpdateCheckedItems(FlagCheckedListBoxItem composite, CheckState cs) { if (composite.value == 0) { UpdateCheckedItems(0); } int sum = 0; for (int i = 0; i < Items.Count; i++) { FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem; if (GetItemChecked(i)) { sum |= item.value; } } if (cs == CheckState.Unchecked) { sum = sum & (~composite.value); } else { sum |= composite.value; } UpdateCheckedItems(sum); }
protected override void OnItemCheck(ItemCheckEventArgs e) { base.OnItemCheck(e); if (isUpdatingCheckStates) { return; } FlagCheckedListBoxItem item = Items[e.Index] as FlagCheckedListBoxItem; UpdateCheckedItems(item, e.NewValue); }
public int GetCurrentValue() { int sum = 0; for (int i = 0; i < Items.Count; i++) { FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem; if (GetItemChecked(i)) { sum |= item.value; } } return(sum); }
protected void UpdateCheckedItems(int value) { isUpdatingCheckStates = true; for (int i = 0; i < Items.Count; i++) { FlagCheckedListBoxItem item = Items[i] as FlagCheckedListBoxItem; if (item.value == 0) { SetItemChecked(i, value == 0); } else { if ((item.value & value) == item.value && item.value != 0) { SetItemChecked(i, true); } else { SetItemChecked(i, false); } } } isUpdatingCheckStates = false; }
public FlagCheckedListBoxItem Add(FlagCheckedListBoxItem item) { Items.Add(item); return(item); }
public bool IsMemberFlag(FlagCheckedListBoxItem composite) { return(IsFlag && ((value & composite.value) == value)); }