net90_PropertyGridHelpers.Converters_EnumTextConverter - dparvin/PropertyGridHelpers GitHub Wiki
Provides a type converter for enums that supports displaying custom user-friendly text for enum fields using the EnumTextAttribute
or LocalizedEnumTextAttribute
.
public class EnumTextConverter : EnumConverter
name | description |
---|---|
EnumTextConverter(…) | Initializes a new instance of the EnumTextConverter class for the given enum type. |
override CanConvertFrom(…) | |
override CanConvertTo(…) | |
override ConvertFrom(…) | Converts from a string or integer to the corresponding enum value. |
override ConvertTo(…) | Converts the specified enum value to a String or Int32 based on the requested destination type. |
override GetStandardValues(…) | Returns a collection of standard enum values for the associated type. |
This converter allows enum values to be shown in a property grid or dropdown list with more readable labels instead of their default names. For localization or specialized labeling, decorate the enum fields with EnumTextAttribute
or LocalizedEnumTextAttribute
.
public enum Status
{
[EnumText("Pending Approval")]
Pending,
[EnumText("Approved")]
Approved,
[EnumText("Rejected")]
Rejected
}
[TypeConverter(typeof(EnumTextConverter))]
public Status Status { get; set; }
- namespace PropertyGridHelpers.Converters
- assembly PropertyGridHelpers
- EnumTextConverter.cs