?
Solved

howto get displayname attribute of an property in a class

Posted on 2007-12-04
1
Medium Priority
?
1,608 Views
Last Modified: 2013-11-25
public class MyClass
    <DisplayName("ISO-code")> _
    Public  Property IsoCode() As String
0
Comment
Question by:ecapro
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 375 total points
ID: 20402462
try with this:

            Dim DisplayName as String
           ' Get the type of MyClass1.
            Dim myType as Type = TypeOf(MyClass1)
            ' Get the property info
            Dim pop as PropertyInfo = myType.GetProperty("DisplayName")
            ' Get attribute list
            Dim attrs() as Object = prop.GetCustomAttribues(TypeOf(DisplayNameAttribute), False)
            ' check if attribute exists
            If attrs.Length > 0
                   DisplayName = DirectCast(attrs(0), DisplayNameAttribute).DisplayName
                   
           
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question