T
Thomas Jespersen
Hello
How can I read the name of a property?
The following pseudo which doesn't work will illustrate what I'm after.
Class MyClasss
Public MyClassID As Guid
Public FullName As String
End Class
Dim myClass as MyClass
'I don't know how or which reflection procdure to use ?Propperty? is the
pseudo code ;-)
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName =
CType(myClass.MyClassID, System.Reflection.?Property?).GetName
myThirdPartyExtraGridControl.FullNameGridColumn.FieldName =
CType(myClass.FullnName, System.Reflection.?Property?).GetName
The reason I want this is because we have a Third Party Grid Control, which
can take a collection of objects. And if FieldName is a valid property it
will display the value. I can use the following code (which works). But this
is not type safe... that is if I change the name of MyClassID to ID I don't
get a compile error but a runtime error.
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName = "MyClassID"
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName = "FullName"
Any help?
Best. regards.
Thomas
How can I read the name of a property?
The following pseudo which doesn't work will illustrate what I'm after.
Class MyClasss
Public MyClassID As Guid
Public FullName As String
End Class
Dim myClass as MyClass
'I don't know how or which reflection procdure to use ?Propperty? is the
pseudo code ;-)
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName =
CType(myClass.MyClassID, System.Reflection.?Property?).GetName
myThirdPartyExtraGridControl.FullNameGridColumn.FieldName =
CType(myClass.FullnName, System.Reflection.?Property?).GetName
The reason I want this is because we have a Third Party Grid Control, which
can take a collection of objects. And if FieldName is a valid property it
will display the value. I can use the following code (which works). But this
is not type safe... that is if I change the name of MyClassID to ID I don't
get a compile error but a runtime error.
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName = "MyClassID"
myThirdPartyExtraGridControl.MyClassIDGridColumn.FieldName = "FullName"
Any help?
Best. regards.
Thomas