Click here to Skip to main content
15,899,825 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Find a Parent Control Recursively

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
22 Sep 2010CPOL 5.3K   1  
Here's the VB.NET version:Public Shared Function FindParentAsTabControl(ByRef startCntrl As Control) As Control Dim retCntrl As Control = Nothing If(startCntrl.Parent IsNot Nothing) If(TypeOf(startCntrl.Parent) is TabControl) retCntrl = startCntrl.Parent ...
Here's the VB.NET version:

VB
Public Shared Function FindParentAsTabControl(ByRef startCntrl As Control) As Control
    Dim retCntrl As Control = Nothing
    If(startCntrl.Parent IsNot Nothing)
        If(TypeOf(startCntrl.Parent) is TabControl)
            retCntrl = startCntrl.Parent
        Else
            retCntrl = FindParentAsTabControl(startCntrl.Parent)
        End if
    End If
    Return(retCntrl)
End Function

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --