Board index » Visual Studio » propertyinfo.setvalue

propertyinfo.setvalue

Visual Studio203
This part is easy:

Dim oControl As Control



oControl = Me.Page.FindControl("TextBox1")



Dim oPropertyInfo As PropertyInfo



oPropertyInfo = oControl.GetType.GetProperty("Text")



oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)



What about in the case when the property may have properties that need to be

changed?



For instance the Infragistics WebTextEdit control, I couldn't quickly find a

vb control example, has a property named "ButtonsAppearance" which has a

property named "CustomButtonToolTip". The following code produces a

targetexception.



oControl = Me.Page.FindControl("WebTextEdit1")



Dim oPropertyInfo As PropertyInfo



oPropertyInfo = oControl.GetType.GetProperty("ButtonsAppearance")



oPropertyInfo =

oPropertyInfo.PropertyType.GetProperty("CustomButtonTooltip")



oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)



I don't believe oControl is the correct target here but am at a loss as to

how to provide the correct target. Any suggestions?


-
 

Re:propertyinfo.setvalue

I wanted to pass on what I have found.



The ButtonsAppearance Property is READ ONLY. So is every other Property

whose Value is not a value type; I only perused Visual Studio and

Infragistics controls. Therefore it will not be possible to make changes to

these properties at runtime. If anyone resolves the TargetException, I'd be

interested in seeing the code.



"Paul" <paulscalf@smmoving.com>wrote in message

Quote
This part is easy:

Dim oControl As Control



oControl = Me.Page.FindControl("TextBox1")



Dim oPropertyInfo As PropertyInfo



oPropertyInfo = oControl.GetType.GetProperty("Text")



oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)



What about in the case when the property may have properties that need to

be

changed?



For instance the Infragistics WebTextEdit control, I couldn't quickly find

a

vb control example, has a property named "ButtonsAppearance" which has a

property named "CustomButtonToolTip". The following code produces a

targetexception.



oControl = Me.Page.FindControl("WebTextEdit1")



Dim oPropertyInfo As PropertyInfo



oPropertyInfo = oControl.GetType.GetProperty("ButtonsAppearance")



oPropertyInfo =

oPropertyInfo.PropertyType.GetProperty("CustomButtonTooltip")



oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)



I don't believe oControl is the correct target here but am at a loss as to

how to provide the correct target. Any suggestions?















-