Solved

howto get displayname attribute of an property in a class

Posted on 2007-12-04
1
1,399 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 125 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 74
Vb. Net application freezes 9 47
Help with exporting to excel 4 28
Sql server, import complete table, using vb.net 9 35
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 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