MATT,
It sounds like you placed your TextBox on the GroupBox control.
Which means your Form contains a GroupBox, and your GroupBox contains a
TextBox control.
You need to recursively look at the controls that are children of the Group
control, something like:
Private Sub SetReadOnly(ByVal parent As Control)
For Each child As Control In parent.Controls
If TypeOf child Is TextBox Then
Dim txb As TextBox = DirectCast(child, TextBox)
txb.ReadOnly = True
txb.BackColor = Color.White
End If
If child.HasChildren Then SetReadonly(child)
Next
End Sub
Then within your form you could call it with:
SetReadOnly(Me)
As Form inherits from Control.
Which recursively looks at the children of all controls searching out
TextBoxes...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net [quoted text, click to view] "MATT" <MATT@discussions.microsoft.com> wrote in message
news:DAFEF43B-4CC0-4EE1-8F9F-21BA65173A57@microsoft.com...
|I have simple code that i use to make each textbox in a form "Read Only":
| For Each ctl In frm.Controls
| If TypeOf ctl Is TextBox Then
| txb = ctl
| txb.ReadOnly = True
| txb.BackColor = Color.White
| End If
| Next ctl
| This code worked fine until I added a Group Control to the form. Now, if
I
| step through the code, I can see that the ctl never "gets to" the
textboxses,
| but it does the group control. If, in the form code, I type "formName."
all
| of the textbox controls appear. If if view "frm.contrls.count" it is
clear
| that the textboxes are not being included in this collection. Could
someone
| explain the Textboxes are excluded from this collection when i add the
group
| control to the form.