Hello, what you seek is called the "reflection" .NET, but using an "interface" seems more appropriate:
Interface:
Code:
Public Interface ImageControl
Property PropertyMagic() As String
End Interface
The implementation on the UserControls Me:
Code:
Public Class UserControl1
Implements ImageControl
Public Property PropertyMagic() As String Implements ImageControl.PropertyMagic
Get
'...
End Get
Set(ByVal value As String)
'...
End Set
End Property
End Class
Public Class UserControl2
Implements ImageControl
Public Property PropertyMagic() As String Implements ImageControl.PropertyMagic
Get
'...
End Get
Set(ByVal value As String)
'...
End Set
End Property
End Class
And finally, with your use foreach in your Form:
Code:
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is ImageControl Then
DirectCast(ctrl, ImageControl).PropertyMagic = "..."
End If
Next
Bookmarks