net472_PropertyGridHelpers.Converters_EnumTextConverter 1 - dparvin/PropertyGridHelpers GitHub Wiki

EnumTextConverter<T> class

A strongly-typed generic version of EnumTextConverter for handling enums with display text annotations in a PropertyGrid.

public class EnumTextConverter<T> : EnumTextConverter
    where T : Enum
parameter description
T The enumeration type whose members are decorated with EnumTextAttribute.

Public Members

name description
EnumTextConverter() Initializes a new instance of the EnumTextConverter class.

Remarks

This converter simplifies using EnumTextAttribute on enum members by automatically associating the generic parameter T as the enum to convert. This enables the property grid to display friendly names for enum values without requiring manual type configuration.

Examples

public enum Status
{
    [EnumText("Pending Approval")]
    Pending,

    [EnumText("Approved")]
    Approved,

    [EnumText("Rejected")]
    Rejected
}

[TypeConverter(typeof(EnumTextConverter<Status>))]
public Status CurrentStatus { get; set; }

See Also

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