net90_PropertyGridHelpers.Attributes_EnumImageAttribute - dparvin/PropertyGridHelpers GitHub Wiki
Associates an image with an Enum field for display in a property grid.
[AttributeUsage(AttributeTargets.Field, Inherited = false)]
public class EnumImageAttribute : Attribute
name | description |
---|---|
EnumImageAttribute() | Initializes a new instance of the EnumImageAttribute class with default values (null image, embedded location). |
EnumImageAttribute(…) | Initializes a new instance of the EnumImageAttribute class with the specified image location. (2 constructors) |
static Get(…) | Retrieves the EnumImageAttribute associated with a given Enum value. |
EnumImage { get; } | Gets the name or resource key of the image associated with the Enum item. |
ImageLocation { get; } | Gets the storage location of the associated image. |
static Exists(…) | Determines whether an EnumImageAttribute exists for the given Enum value. |
static GetEnumImage(…) | Retrieves the name of the image associated with a given Enum value. |
This attribute allows an Enum field to have an associated image, which can be used in UI components such as property grids. The image is identified by a text-based key and can be stored as an embedded resource or in an external location. To display the image in a property grid, apply this attribute to the Enum items and use ImageTextUIEditor
as the UI editor for the corresponding property.
public enum Status
{
[EnumImage("PendingIcon.png")]
Pending,
[EnumImage("ApprovedIcon.png")]
Approved,
[EnumImage("RejectedIcon.png", ImageLocation.External)]
Rejected
}
- class ImageTextUIEditor
- namespace PropertyGridHelpers.Attributes
- assembly PropertyGridHelpers
- EnumImageAttribute.cs