On Nov 22, 2:22 am, dig_dug_d <doug.dimic...@gmail.comwrote:
Hello,
I have been struggling with the SetValue method when trying to use
indexed items. I can't figure out what needs to be done to create
the "index As Object()" parameter. Juding from the lack of examples
out there on the net I am sure many people would love to see how this
mysterious parameter works in a real example. Anyone?
Thanks in advance,
Doug
Hi Doug,
If I am not mistaken, you must be talking with respect to
setting property values using Reflection ? If it is so, you can use
the following syntax to set a value for the property
ctl.GetType().InvokeMember(strProperty, BindingFlags.SetProperty,
Nothing, ctl, New Object() {strControlResource})
I will explain you all the things in this statement.
ctl - Control object. You can replace this with whatever you want, but
having the GetType() method.
InvokeMember is called to set a named property to some value provided.
strProperty - Name of the property to be set. For example - Text
BindingFlags.SetProperty denotes that we need to set the property.
the last parameter is of special interest now, since it is the actual
value that would be set to the property. Here I have created an Object
array on fly containing the only item strControlResource.
Hope this helps.
If I have misunderstood your question please revert back with relevant
details, so that I may help you.
Thanks,
coolCoder.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find this post helpful, please rate it.