GetProperty

J

JC Voon

Hi:

How to use GetProperty to return the TextBox.Font.Name property ?

Dim propInfo As PropertyInfo = ctrl.GetType.GetProperty("Font",
BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static
Or BindingFlags.Instance Or BindingFlags.IgnoreCase)

will return the Font property, how to reference the Name property in
then propInfo ?

Thanks
JCVoon
 
H

Herfried K. Wagner [MVP]

JC said:
How to use GetProperty to return the TextBox.Font.Name property ?

Dim propInfo As PropertyInfo = ctrl.GetType.GetProperty("Font",
BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static
Or BindingFlags.Instance Or BindingFlags.IgnoreCase)

will return the Font property, how to reference the Name property in
then propInfo ?

Untested: 'PropertyInfo' has a 'PropertyType' property that will return
the type of the property. Then you can use 'GetProperty' on the font's
type to get the name property.
 
J

JC Voon

Herfried K. Wagner:
Untested: 'PropertyInfo' has a 'PropertyType' property that will return
the type of the property. Then you can use 'GetProperty' on the font's
type to get the name property.

Thanks for the reply, now i can get the Font.Name property,

Public Const MemberAccess As BindingFlags = BindingFlags.Public Or
BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.Instance
Or BindingFlags.IgnoreCase

Dim fontPropInfo As PropertyInfo = ctrl.GetType.GetProperty("Font",
MemberAccess)
Dim fontNamePropInfo As PropertyInfo = fontPropInfo
..PropertyType.GetProperty("Name")

But how to Get or Set the property value, The GetValue and SetValue
need the instance reference, but i don't know how to get the reference
from the fontNamePropInfo

fontNamePropInfo.GetValue( ??, nothing )

Thanks
JCVoon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top