469,076 Members | 1,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

Retrieve the property name - How To?

Imaginate you have one method that accept some arguments like:

1- a control
2- un Type
(MyType)
3- el nombre de una Propiedad "PropertyName"

Example:

.Add(Me.txtCustomerID, GetType(Customer), "CustomerID")

Inside this method, I use reflection tu scan all properties.

I want avoid to use literals like "CustomerID" to refer the properties. I
would wish another strong method to retrieve the Name of the property.

Any help will be appreciated

TIA
Antonio

Sep 26 '05 #1
3 1730
You mean that you need a method to reference a property without its
name ?

Sep 27 '05 #2
Antonio,

You are using reflection (late binding). With that it gets its information
at runtime. Why would you use this time consuming method, while you want in
fact strong typed names.

Just don't use late binding and don't even use collections.

Just my thought,

Cor
Sep 27 '05 #3

Hi,

Reflection is great and powerful... I think that time consuming it is not
perceivable in commercial applications.
There is a function GetType that allow me get the Name of a type as string.
Ex:
Dim TypeName as String = GetType(MyType).Name --> return
"MyType"
what I am trying to do, but I not sure that is possible, is something like
this.
Dim PropertyName as String = GetMemberInfo(MyType.MyProperty).Name --->
return "MyProperty"
Properties on my busines objects contains custom attributes.
Ex:

<Serializable(), Entity(TableStorage:="ANALISIS", Description:="Analisis")>
_
Public Class Analisis : Inherits BusinessBase

.....

<Entity(DataField:="ANA_PUNTO_INGRESO", Key:=1, IsRequired:=True)> _
Public Property PuntoIngreso() As Integer
Get
Return mPuntoIngreso
End Get
Set(ByVal Value As Integer)
mPuntoIngreso = Value
End Set
End Property
End Class

I want to be able to retrieve DataField attrib of any property without using
the property name as string. For this reason I need a function that does
this for me.

Antonio
"Cor Ligthert [MVP]" <no************@planet.nl> escribió en el mensaje
news:eZ**************@TK2MSFTNGP09.phx.gbl...
Antonio,

You are using reflection (late binding). With that it gets its information
at runtime. Why would you use this time consuming method, while you want
in fact strong typed names.

Just don't use late binding and don't even use collections.

Just my thought,

Cor

Sep 27 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Antonio Paglia | last post: by
1 post views Thread by Mel | last post: by
2 posts views Thread by kjqua | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.