net472_PropertyGridHelpers.Controls_FlagCheckedListBox - dparvin/PropertyGridHelpers GitHub Wiki

FlagCheckedListBox class

A custom CheckedListBox control designed for editing properties backed by [Flags] enumerations. It presents each enum value as a checkbox, allowing users to select multiple values that combine into a composite flag. This control is typically hosted in a drop-down editor (e.g., UITypeEditor) using DropDownVisualizer to support property editing within a PropertyGrid.

public class FlagCheckedListBox : CheckedListBox, IDropDownEditorControl

Public Members

name description
FlagCheckedListBox() Initializes a new instance of the FlagCheckedListBox class.
Context { get; set; } Gets or sets the type descriptor context in which the control is being used.
Converter { get; set; } Gets or sets the EnumConverter used to control how the enum values are displayed in the list.
Culture { get; set; } Gets or sets the culture to use for localization or formatting.
EnumValue { get; set; } Gets or sets the current enum value represented by the checked items in the list. This property serves as the main interface for binding a flags-based enum to the control.
Value { get; set; } Gets or sets the composite enum value represented by the checked items, in a non-generic interface-friendly way.
event ValueCommitted Occurs when the user has finished editing the selection and commits the current value.
Add(…) Adds a new item to the checklist with the specified bitwise value and display caption. (2 methods)
Clear() Removes all items from the checklist and resets its state.
GetCurrentValue() Gets the composite integer value representing all currently checked flags.

Remarks

When the associated enum is set via the EnumValue property, the control automatically populates with all defined enum values and checks those corresponding to the current composite value. As checkboxes are toggled, the internal representation is updated accordingly. This control assumes that the enum is decorated with the FlagsAttribute; an exception will be thrown otherwise. Optional display customization is supported via a custom EnumConverter assigned to Converter.

Examples

Typical usage:

[Editor(typeof(FlagEnumUIEditor), typeof(UITypeEditor))]
public MyFlagsEnum FlagsProperty { get; set; }

See Also

⚠️ **GitHub.com Fallback** ⚠️