brentman
Member
I have an entry form that I would like to disable entry more and have it read-only. I seem to be missing the boat on dynamically controlling controls. I have been able to grab the name of a control, etc but never been able to change properties dynamically. Here is what I have, any help would be appreciated.
Dim c As Control
Dim txt As System.Windows.Forms.TextBox
For Each c In tabcontrol1.Controls
If TypeOf c Is TextBox Then
txt = CType(c, TextBox)
txt.ReadOnly = True
End If
Next
This code does nothing at all. I assume it is because I am setting the property of a control-typed variable and not the actual control itself.
I am able to disable all controls by doing:
for each c in tabcontrol1.controls
c.enabled = false
next
But that isn't what I need. Any ideas? Thanks.
Dim c As Control
Dim txt As System.Windows.Forms.TextBox
For Each c In tabcontrol1.Controls
If TypeOf c Is TextBox Then
txt = CType(c, TextBox)
txt.ReadOnly = True
End If
Next
This code does nothing at all. I assume it is because I am setting the property of a control-typed variable and not the actual control itself.
I am able to disable all controls by doing:
for each c in tabcontrol1.controls
c.enabled = false
next
But that isn't what I need. Any ideas? Thanks.