Dan (DevExpress)
05.21.2007
-
To solve this problem, you can execute the following steps:
1) Set the standard System.ComponentModel.DescriptionAttribute to the enum fields, whose caption you want to change.
2) Implement a custom PropertyEditor, using the source code of the EnumPropertyEditor, used for displaying the enum type properties by default (\Program Files\Developer Express Inc\eXpressApp Framework v8.2\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Win\Editors\EnumPropertyEditor.cs), and change the EnumImagesLoader class constructor, as shown in the following code:
public EnumImagesLoader(Type enumType) { EnumDescriptor descriptor = new EnumDescriptor(enumType); imageCollection = new ImageCollection(); comboboxItems = new List<ImageComboBoxItem>(descriptor.Values.Length); foreach (object value in descriptor.Values) { ImageInfo imageInfo = descriptor.GetImageInfo(value); int imageIndex = -1; if (!imageInfo.IsEmpty) { imageCollection.AddImage(imageInfo.Image); if (imageCollection.Images.Count == 1) { imageCollection.ImageSize = imageInfo.Image.Size; } imageIndex = imageCollection.Images.Count - 1; } string caption = string.Empty; FieldInfo fInfo = enumType.GetField(value.ToString()); foreach (Attribute attr in Attribute.GetCustomAttributes(fInfo)) { if (attr.GetType() == typeof(DescriptionAttribute)) { caption = ((DescriptionAttribute)attr).Description; } } if (caption == "") { caption = fInfo.Name; } comboboxItems.Add(new ImageComboBoxItem(caption, GetEnumValue(value), imageIndex)); } }3) Use a newly implemented PropertyEditor as a default for the enum type properties.
For additional information, please refer to the following help topic: Implement Custom Property Editors.
I've also attached my sample project.Thanks,
Anatol
You must
log in
or
register
to leave comments
1 Solution
Starting with version 12.2, use the XafDisplayName attribute to localize an enumeration value instead of the Description one supported in version 9.2.
See http://www.devexpress.com/Support/WhatsNew/DXperience/files/12.2.2.bc.xml#BC1737 for more details.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+