Thanks to all that replied and helped me solve this problem.
I did use the PropertyInfo in System.Reflections. Using P as the
propertyinfo variable, I was able to get both the name of the property as
well as it's value like this:
For Each p As PropertyInfo In
obj.GetType().GetProperties(BindingFlags.Public Or BindingFlags.Instance Or
BindingFlags.DeclaredOnly)
dr.Item(p.Name) = p.getvalue(obj, Nothing)
etc.
As you can see, I was able to retrieve both the name, p.Name, as well as the
value, p.getvalue(obj,nothing) for the property. The only thing that gave
me a little trouble was the 1st parameter of the getvalue method. It has to
be the "object" whose properties you are looking at. Also, since I am
scanning classes that are derived from other classes, I only wanted to "see"
the properties that I declared. Note the parameters on the GETPROPERTIES
method. The way they work is that you need to "or" all of the ones you
want. Specifying "bindingflags.declaredonly" by itself will not work...
Other than that, it all worked as expected. Thanks again to everybody.
John
"Chris Dunaway" <du******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Have you looked at the PropertyGrid? It is designed for just that
purpose.
However, to get the property names for an object, you can use code
similar to this:
Imports System.Reflection
Dim MyType As System.Type = MyObject.GetType
Dim aProps() As PropertyInfo = MyType.GetProperties()
For Each pi As PropertyInfo in aProps
Debug.WriteLine(pi.Name)
Next