net472_PropertyGridHelpers.Attributes_EnumTextAttribute - dparvin/PropertyGridHelpers GitHub Wiki
Specifies a user-friendly text representation for an Enum field, primarily for display in a property grid or UI elements.
[AttributeUsage(AttributeTargets.Field, Inherited = false)]
public class EnumTextAttribute : Attribute
name | description |
---|---|
EnumTextAttribute(…) | Initializes a new instance of the EnumTextAttribute class. |
static Get(…) | Retrieves the EnumTextAttribute applied to the specified Enum field. (2 methods) |
EnumText { get; } | Gets the custom text associated with the Enum field. |
static Exists(…) | Determines whether the specified Enum value has an associated EnumTextAttribute . |
This attribute can be applied to individual Enum fields to provide a custom display text. This is useful when showing Enum values in a PropertyGrid, dropdowns, or UI components where a more descriptive label is needed instead of the raw Enum name.
public enum Status
{
[EnumText("Pending Approval")]
Pending,
[EnumText("Approved")]
Approved,
[EnumText("Rejected")]
Rejected
}
- namespace PropertyGridHelpers.Attributes
- assembly PropertyGridHelpers
- EnumTextAttribute.cs