Finding embedded controls?

I

IdleBrain

Hello,
I am trying to write code to clear all the textboxes on a VB.NET
windows form using:

Dim ctrl As Control
For Each ctrl In Me.Controls
'Add your code here
If TypeOf ctrl Is TextBox Then
ctr.text = ""
End If
Next

When I debug, I realized that none of the text boxes are being
recognized as they are present within tabcontrol and embedded within a
frame.

So how exactly do we find out all the controls that are present on a
tabpage and are embedded within a frame?

Any Help is appreciated.
 
I

IdleBrain

I found out the solution...
Dim ctrl, ctrl2 As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is Panel Then
For Each ctrl2 In ctrl.Controls
If ctrl2.Text = "Go" Then
' Do Something
End If
Next
End If
 
G

Guest

That works if you are only looking for the panel's child controls. What if
you have a panel within a panel that contains textboxes? Try recursion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top