Use the propertyInfo to setValues

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 :)
 
P

Phill W.

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.
 

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