net472_PropertyGridHelpers.UIEditors_DropDownVisualizer 1 - dparvin/PropertyGridHelpers GitHub Wiki

DropDownVisualizer<TControl> class

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.

Public Members

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.

Remarks

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

Examples

A simple calculator bound to a decimal property:

[Editor(typeof(DropDownVisualizer<CalculatorControl>), typeof(UITypeEditor))]
public decimal Total { get; set; }

See Also

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