I have a user control that I use for a base for a number of inherited controls:
VB Code:
Public Class JobDisplayBlock Inherits System.Windows.Forms.UserControl ' ' End Class
From this class, I inherit a number of different classes, as below. All the inherited classes have a method called Clear, which I call to reset text, numbers, etc within the class:
VB Code:
Public Class StationDisplay Inherits JobDisplayBlock Public Sub Clear() 'Code to zero counts and clear text, etc End Sub End Class
How can I loop through all these classes and call the Clear method on each one, just by checking if the type of object is the base class?
VB Code:
Public Shared Sub ClearJobLabels(ByRef ctlColl As Control.ControlCollection) For Each ctl As Control In ctlColl If TypeOf ctl Is JobDisplayBlock Then 'Call Clear method on all inherited classes End If If ctl.HasChildren Then ClearJobLabels(ctl.Controls) End If Next ctl End Sub
Hope that makes sense, thanks.
EDIT: I am using VB2003 standard.





Reply With Quote