Use the propertyInfo to setValues

  • Thread starter Thread starter Mr. X.
  • Start date Start date
M

Mr. X.

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 :)
 
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.
 
Back
Top