J
Joergen Bech
I have written the following snippet (which works), but is there a
more "correct" way to do this? Any way of getting rid of the
loop?
TIA,
Joergen Bech
---snip---
Private Function IsSystemWindowsFormsControl(ByVal o As
Object) As Boolean
If o Is Nothing Then
Return False
Else
Return ObjectInheritsFromClass(o,
GetType(System.Windows.Forms.Control))
End If
End Function
Private Function ObjectInheritsFromClass(ByVal ctrl As Object,
ByVal ObjectType As Type) As Boolean
Dim ct As Type = ctrl.GetType
Do While Not ct Is Nothing
If ct.Equals(ObjectType) Then
Return True
Else
ct = ct.BaseType
End If
Loop
Return False
End Function
more "correct" way to do this? Any way of getting rid of the
loop?
TIA,
Joergen Bech
---snip---
Private Function IsSystemWindowsFormsControl(ByVal o As
Object) As Boolean
If o Is Nothing Then
Return False
Else
Return ObjectInheritsFromClass(o,
GetType(System.Windows.Forms.Control))
End If
End Function
Private Function ObjectInheritsFromClass(ByVal ctrl As Object,
ByVal ObjectType As Type) As Boolean
Dim ct As Type = ctrl.GetType
Do While Not ct Is Nothing
If ct.Equals(ObjectType) Then
Return True
Else
ct = ct.BaseType
End If
Loop
Return False
End Function