Troy,
You have the "truly dynamic solution": Late Binding, Reflection or
CallByName! (which are all based on Reflection).
DirectCast & CType are not intended for "truly dynamic solutions".
DirectCast is intended for where you know the type of the object, but that
object is in a variable of a different type, normally this different type
will be a base type. CType is there for when you an object of one type and
you want to convert it to an object of a different type (think of CType as
Convert Type).
DirectCast & CType are there to avoid the "truly dynamic solution"! As the
"Truly dynamic solution" is expensive at runtime.
The other option to avoid the overhead of Reflection is to use an Interface,
which someone else suggested, which is the route I would normally take! The
interface avoids "you have to code them specifically" as it delegates that
code to each class (encapsulation). This of course assumes that each control
"binds" to a specific property of that control. Of course if each control
has multiple properties that could be bound to, this won't work as well...
Public Interface TheChanger
Public Property TheProperty As String
End Interface
Public Class SpecialControl1
Implements TheChanger
Public Property TheProperty() As String Implements
TheChanger.TheProperty
Get
Return Me.Text
End Get
Set(ByVal value As String)
Me.Text = value
End Set
End Property
End Class
Public Class SpecialControl2
Implements TheChanger
Public Property TheProperty() As String Implements
TheChanger.TheProperty
Get
Return Me.Widget.ToString
End Get
Set(ByVal value As String)
Me.Widget = Widget.FromString(value)
End Set
End Property
End Class
BTW: Is there a reason you are attempting on building your own binding
mechanism on top of the .NET binding mechanism. What are you needing that
the .NET binding does not provide?
Hope this helps
Jay
"Troy Stauffer" <ts*******@commandalkon.com> wrote in message
news:u0**************@TK2MSFTNGP12.phx.gbl...
Thanks, i guess i just hate doing that because if you ever add new ones
into the fold, you have to code them specifically, whereas a truly
dynamic solution would just pick up on it. Not only are my controls not
know but which property to look at is not known. So a truly dynamic
solution would just warm my heart. Thanks for the post back anyhow
Troy B. Stauffer
Jack of all trades, master of none :)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!