I got the DisplayName this way:
private string getDisplayName ( MemberInfo mi ) {
object[] atts = mi.GetCustomAttributes( typeof( DisplayNameAttribute ),
false );
if(atts.Length 0) {
DisplayNameAttribute da = atts[0] as DisplayNameAttribute;
return da.DisplayName;
}
return mi.Name;
}
Then I use it in my foreach(PropertyInfo p in properties)
mything.label = getDisplayName(p);
Found info here:
http://forums.devx.com/showpost.php?...65&postcount=2
Thank you
Tom Shelton wrote:
On 2006-11-30, Charles Bazi <cb***@noos.frwrote:
>Hi,
I have some properties using System.ComponentModel.DisplayName
How can I retrieve that value using Reflection ?
TIA
Look at system.reflection.propertyinfo. That will let you call the property.
You can get the property using one of the Type.GetProperty overloads.
--
Tom Shelton