Really, automating the process is better by creating a recursive method like Greg was talking about. And instead of testing on a name, if you know the control type or if a certain value on that control will be set, you could test on it instead of a name:Private Function GetTextControls(Byval testControls As ControlCollection) As System.Collection.Generic.List(Of Control)
'-- Establish Locals
Dim r As New List(Of Control)
For each ctrl As Control in testControls
'-- Check for a textbox type
If ctrl.GetType().IsSubClassOf(GetType(System.Windows.Forms.TextBox)) Then
'-- Add the control to the collection
r.Add(ctrl)
End If
'-- See if there are additional children to check for
If ctrl.Controls.Count > 0 Then r.AddRange(GetTextControls(ctrl.Controls))
Next
End Function
Then you could call the method in the form constructor or load like this:
'-- Get all of the text controls
r.AddRange(GetTextControls(Me.Controls))
'-- Then add your logic to cycle through the collection and do whatever you need to
For each ctrl as Control in r
ctrl.Enabled = False
Next