dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: beginner
Nov 25, 2002

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


FindControlRecursive - Find a control in a hierarchy of controls

' Find a control in a hierarchy of controls
' Example:
'   Dim txtCtl As Control = FindControlRecursive(DataGrid1, "FirstNameTextBox")

Function FindControlRecursive(ByVal ctrl As Control, _
    ByVal id As String) As Control
    ' Exit if this is the control we're looking for.
    If ctrl.ID = id Then Return ctrl

    ' Else, look in the hiearchy.
    Dim childCtrl As Control

    For Each childCtrl In ctrl.Controls
        Dim resCtrl As Control = FindControlRecursive(childCtrl, id)
        ' Exit if we've found the result
        If Not resCtrl Is Nothing Then Return resCtrl
    Next
End Function


' Note: This code is taken from Francesco Balena's
' "Programming Microsoft Visual Basic .NET" - MS Press 2002, ISBN 0735613753
' You can read a free chapter of the book at 
' http://www.vb2themax.com/HtmlDoc.asp?Table=Books&ID=101000
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date