net472_PropertyGridHelpers.UIEditors_DropDownVisualizer 1 - dparvin/PropertyGridHelpers GitHub Wiki
A reusable drop-down UITypeEditor that hosts a custom Windows Forms control to edit a property value.
public class DropDownVisualizer<TControl> : UITypeEditor, IDisposable
where TControl : Control, IDropDownEditorControl, new()
parameter | description |
---|---|
TControl | The type of the Windows Forms control to be shown in the dropdown. Must implement IDropDownEditorControl . |
name | description |
---|---|
DropDownVisualizer() | The default constructor. |
DropDownControl { get; } | The instance of the drop-down control currently used by the editor. This can be configured before editing starts (e.g., setting styles, converters, or event handlers). |
Dispose() | Releases unmanaged and - optionally - managed resources. |
override EditValue(…) | Displays the editor control in a dropdown and returns the updated value after editing completes. |
override GetEditStyle(…) | Gets the edit style. |
This class simplifies building custom UI editors for use in PropertyGrid by wrapping a control that supports editing a specific data type. The dropdown closes automatically when the control raises the ValueCommitted
event. To use it, decorate your property with:
[Editor(typeof(DropDownVisualizer<MyControl>), typeof(UITypeEditor))]
public MyValueType MyProperty { get; set; }
The provided control type must: - Be a subclass of Control - Implement IDropDownEditorControl
- Have a parameterless constructor
A simple calculator bound to a decimal property:
[Editor(typeof(DropDownVisualizer<CalculatorControl>), typeof(UITypeEditor))]
public decimal Total { get; set; }
- interface IDropDownEditorControl
- namespace PropertyGridHelpers.UIEditors
- assembly PropertyGridHelpers
- DropDownVisualizer.cs