From: Mr. X. on
Hello.
I am using the propertyInfo type.
dim pi as propertyInfo
pi = myClass.getType().getProperty("myPropertyName", BindingFlags.Public Or
BindingFlags.Instance)

myPropertyName may be any property, such as borderLevel, etc.

I want to set myPropertyName to a specific value, as propertyGrid does (I
mean - by sending it a string).

I see there are methods : getGetMethod, and getSetMethod - Are those method
the property editors ?
Can I use those method to solve the problem ?

How can I do that ?

Thanks :)

From: Phill W. on
On 21/06/2010 13:45, Mr. X. wrote:

> I am using the propertyInfo type.
> dim pi as propertyInfo
> pi = myClass.getType().getProperty("myPropertyName", BindingFlags.Public
> Or BindingFlags.Instance)
>
> myPropertyName may be any property, such as borderLevel, etc.
>
> I want to set myPropertyName to a specific value, as propertyGrid does
> (I mean - by sending it a string).

You need to convert the String values into the correct Type for the
property or find a converter that will do the job for you.
This isn't VB6 - you can't get away with half as much as you used to and
Evil Type Coercion is all but gone. You simply must get things into the
right Type.

> I see there are methods : getGetMethod, and getSetMethod - Are those
> method the property editors ?

No; those are the methods called when your code wants to "get" and "set"
the property's value (everything boils down to a method in .Net, even
though they look like properties to you and me).

HTH,
Phill W.