net472_PropertyGridHelpers.Controls_FlagCheckedListBox - dparvin/PropertyGridHelpers GitHub Wiki
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
name | description |
---|---|
FlagCheckedListBox() | Initializes a new instance of the FlagCheckedListBox class. |
Converter { get; set; } | Gets or sets the EnumConverter used to control how the enum values are displayed in the list. |
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 value to be edited. |
event ValueCommitted | Event raised when the user indicates they are done editing. |
Add(…) | Adds the specified value. (2 methods) |
Clear() | Clears this instance. |
GetCurrentValue() | Gets the current value. |
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
.
Typical usage:
[Editor(typeof(FlagEnumUIEditor), typeof(UITypeEditor))]
public MyFlagsEnum FlagsProperty { get; set; }
- interface IDropDownEditorControl
- class DropDownVisualizer<TControl>
- class FlagEnumUIEditor
- class FlagEnumUIEditor<T>
- namespace PropertyGridHelpers.Controls
- assembly PropertyGridHelpers
- FlagCheckedListBox.cs