|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get property at runtimeHi, im making a tool used to Skin controls. Im trying to make it so a user
can change any property they want by passing the property in....for example Public Sub ChangeProperty(Byval Prop as Propert, byval Value as Object) now obviously that doesnt work because Property isnt a type...how can i do this? thanks -- -iwdu15 nevermind, i figured it out....heres some code for any who need it
Public Sub ChangeProperty(ByVal PropertyName As String, ByVal val As Object, ByVal ctrl As Control) ''get the objects type and property info, passing in the name of the property to get Dim objType As Type = ctrl.GetType() Dim propInfo As PropertyInfo = objType.GetProperty(PropertyName) propInfo.SetValue(ctrl, val, Nothing) Catch ex As Exception End Try End Sub -- -iwdu15 "iwdu15" <jmmgoalsteratyahoodotcom> schrieb: In addition to the other reply, check out VB's handy 'CallByName' function.> Hi, im making a tool used to Skin controls. Im trying to make it so a user > can change any property they want by passing the property in....for > example > > Public Sub ChangeProperty(Byval Prop as Propert, byval Value as Object) > > now obviously that doesnt work because Property isnt a type...how can i do > this? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
enter key press
Database Connection Designer Variables About deleting file on Vista 64bit Newbie: error trying to save directory path to database Working with a database How to set an objects property using Reflection PIAs for Excel 9.0 Make Code Fail Key Validation How Do I Kill Non-Printable Characters? Select All CheckBoxes |
|||||||||||||||||||||||