Class DropDownList<TEnum>
A type-safe dropdown control for selecting a single value from an enum. Provides the same interface as OptionSelector<TEnum> but rendered as a compact dropdown list.
public sealed class DropDownList<TEnum> : DropDownList, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable, IValue<string>, IValue where TEnum : struct, Enum
Type Parameters
TEnumThe enum type to display and select from.
- Inheritance
-
DropDownList<TEnum>
- Implements
- Inherited Members
- Extension Methods
Remarks
DropDownList<TEnum> and OptionSelector<TEnum> are interchangeable when the data source is an enum. Both expose a typed Value property and a typed ValueChanged event. They differ only in appearance: DropDownList<TEnum> is a compact single-line dropdown, while OptionSelector<TEnum> shows all options as checkboxes.
The dropdown source is automatically populated from TEnum values in the constructor.
Usage Example:
var dropdown = new DropDownList<DayOfWeek> ();
dropdown.Value = DayOfWeek.Monday;
dropdown.ValueChanged += (s, e) => Console.WriteLine ($"Selected: {e.Value}");
Constructors
- DropDownList()
Initializes a new instance of the DropDownList<TEnum> class. Automatically populates the dropdown source from
TEnumvalues.
Properties
- Value
Gets or sets the currently selected enum value.
Events
- ValueChanged
Raised when the selected value changes. Provides the new value as
TEnum?.