How to determine if an object class is indirectly inherited from a specific type?
- From: Joergen Bech <jbech<NOSPAM>@<NOSPAM>post1.tele.dk>
- Date: Fri, 19 Aug 2005 13:10:23 +0200
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
.
- Follow-Ups:
- Prev by Date: Re: CreateDIBSection from GDI32?
- Next by Date: Re: Saving drawing graphics
- Previous by thread: How to convert user-defined custom format date string to date value
- Next by thread: Re: How to determine if an object class is indirectly inherited from a specific type?
- Index(es):
Relevant Pages
|