DisplayNameAttribute on enumerated types?

B

batvanio

Hi,

I was trying to use a PropertyGrid control to display the properties of
one particular class. Now, one of the class properties is of enum type
( its value is limited to a set of values). I can apply the DisplayName
attribute to the property itself (which will give me a human friendly
name of the property itself).
When you have an enum property, it automatically displays as a combobox
in the Property Grid, which is very nice. However, when I open that
particular element in the PropertyGrid, it would display the
identifiers of all the enumerated values, which is ugly (I guess no one
likes to see in a GUI the guts of the softwrae, like identifiers like
myThirdOfFivePossibleValues).

I would like to be able to apply the DisplayName attribute to each
possible value from the enum type, so when users click on that
particular property, they will see a nice list of human friendly
descriptions instead of identifiers. However, it says it cannot be
applied to enums, only to properties...

Any idea for a workaround?

Thanks,
Ivan
 
G

Guest

Hello Ivan,

I don't think this is feasible with the MSPG. I was not sure and
checked on the jfo's coding blog where I thought I had seen this
information previously but unfortunately this was related to the
BrowsableAttribute that one can now apply on enum fields.

However Smart PropertyGrid.Net is capable of customizing the displayed
values, not only for enum fields but for any type, and dynamically. If
you have any question about it, just contact me at
http://www.visualhint.com/helpdesk

Best regards,

Nicolas Cadilhac
VisualHint - http://www.visualhint.com
Home of Smart PropertyGrid.Net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top