public FlagCheckedListBoxItem Add(ulong v, string c) { FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c); this.Items.Add(item); return(item); }
protected override void OnItemCheck(ItemCheckEventArgs e) { base.OnItemCheck(e); if (this.isUpdatingCheckStates) { return; } FlagCheckedListBoxItem item = this.Items[e.Index] as FlagCheckedListBoxItem; if (item.Value == 0) { this.flagValue = 0; } else if (e.NewValue == CheckState.Checked) { this.flagValue |= item.Value; } else if (e.NewValue == CheckState.Unchecked) { this.flagValue &= ~item.Value; } this.UpdateCheckedItems(); this.OnFlagValueChanged(); }
protected ulong GetCurrentValue() { ulong sum = 0; for (int i = 0; i < this.Items.Count; i++) { FlagCheckedListBoxItem item = this.Items[i] as FlagCheckedListBoxItem; if (this.GetItemChecked(i)) { sum |= item.Value; } } return(sum); }
protected void UpdateCheckedItems() { this.isUpdatingCheckStates = true; // Iterate over all items for (int i = 0; i < this.Items.Count; i++) { FlagCheckedListBoxItem item = this.Items[i] as FlagCheckedListBoxItem; if (item.Value == 0) { this.SetItemChecked(i, flagValue == 0); } else { this.SetItemChecked(i, (item.Value & flagValue) == item.Value && item.Value != 0); } } this.isUpdatingCheckStates = false; }
public FlagCheckedListBoxItem Add(ulong v, string c) { FlagCheckedListBoxItem item = new FlagCheckedListBoxItem(v, c); this.Items.Add(item); return item; }