F
filipk69
Could someone point me in the right direction, please.
I have an enum something like this:
enum TextFieldType
{
[Description("Field ABC"), FieldLabel("abc field")] FieldABC = 3000,
[Description("Field XYZ"), FieldLabel("xyz field")] FieldXYZ = 3001,
…..
…..
}
Where FieldLabel is a custom attribute.
I have a class TextEntry that contains properties: TextFieldType and Content.
I have a generic list of TextEntry objects that I'm looping through and outputting
info to the screen and what I would like to do is to display the text inside
the FieldLabel attribute and the value in "Content".
abc field: Here is the content of the ABC Type field...
xyz field: Here is the content of the XYZ Type field…
…
....
Getting the "Content" is not an issue, but how do I get the value from the
"FieldLabel". I know I have to use reflection here but the only samples I
found show retrieving custom attribute from a class or a method. I tried
to tweek the 'method' example with no success.
Any help would be appreciated.
Thanks Filip
I have an enum something like this:
enum TextFieldType
{
[Description("Field ABC"), FieldLabel("abc field")] FieldABC = 3000,
[Description("Field XYZ"), FieldLabel("xyz field")] FieldXYZ = 3001,
…..
…..
}
Where FieldLabel is a custom attribute.
I have a class TextEntry that contains properties: TextFieldType and Content.
I have a generic list of TextEntry objects that I'm looping through and outputting
info to the screen and what I would like to do is to display the text inside
the FieldLabel attribute and the value in "Content".
abc field: Here is the content of the ABC Type field...
xyz field: Here is the content of the XYZ Type field…
…
....
Getting the "Content" is not an issue, but how do I get the value from the
"FieldLabel". I know I have to use reflection here but the only samples I
found show retrieving custom attribute from a class or a method. I tried
to tweek the 'method' example with no success.
Any help would be appreciated.
Thanks Filip