By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,206 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,206 IT Pros & Developers. It's quick & easy.

Finding embedded controls?

P: n/a
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.

Sep 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Sep 26 '06 #2

P: n/a
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.
--
Dennis in Houston
"IdleBrain" wrote:
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

Sep 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.