Home > Archive > Visual Basic Syntax > February 2006 > simple way to make all fields in a frame locked
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
simple way to make all fields in a frame locked
|
|
| Mavrick 2006-02-01, 8:04 am |
| Hiya guys and gals
All I'm sure this must be so simple !
Have a form with two frames, the data in the top frame changes when the
selected line in the botton frame changes, based upon what the data is,
all the fields in the top frame should be locked or not enabled.
Question is do I really have to
me.field1.vis = hidden
me.field2.vis = hidden
me.field3 vis = hidden
etc etc times 30
this would be ideal
can I not do some sort of me.frame.fields.all.locked = true
or even
for each fields in frame1.fields
with something
.locked = true
type thing
just I'm sure this should be possible and have a mass load of fields in
the top frame
Any answer are gratefully received
| |
| Jeff Johnson [MVP: VB] 2006-02-01, 7:09 pm |
|
"Mavrick" <igarratt@ntlworld.com> wrote in message
news:1138799829.017111.40190@g44g2000cwa.googlegroups.com...
> Have a form with two frames, the data in the top frame changes when the
> selected line in the botton frame changes, based upon what the data is,
> all the fields in the top frame should be locked or not enabled.
> can I not do some sort of me.frame.fields.all.locked = true
No.
> or even
>
>
> for each fields in frame1.fields
> with something
> .locked = true
You can loop through all the controls on the form and check their Container
property to set if it Is the top frame.
| |
| Ken Halter 2006-02-01, 7:09 pm |
| "Mavrick" <igarratt@ntlworld.com> wrote in message
news:1138799829.017111.40190@g44g2000cwa.googlegroups.com...
> Hiya guys and gals
>
>
> All I'm sure this must be so simple !
>
>
> Have a form with two frames, the data in the top frame changes when the
>
> selected line in the botton frame changes, based upon what the data is,
>
> all the fields in the top frame should be locked or not enabled.
If you grab the 'Gradient Frame' below, it truly is easy.
'===========
Option Explicit
Private Sub Command1_Click()
Static bEnabled As Boolean
Dim c As Control
'First time here disables, next time, enables
For Each c In GradFrame1.ChildControls
c.Enabled = bEnabled
Next
bEnabled = Not bEnabled
End Sub
Private Sub Form_Load()
'Make it look like a "plain Jane" frame
With GradFrame1
.ShowGradient = False
.GradBlend0 = vbButtonFace
.BorderStyle = tbNone
.FrameBorderStyle = tbFrame
.Caption = "Test This"
End With
End Sub
'===========
Also, if you want to collect all controls in that frame in Form_Load, here's
a way to find them....
Find Controls in a Container
http://www.vbsight.com/Code.htm
Once you have them in a collection, you can easily enable/disable, show/hide
them, whatever you want. It's best to do it at Form_Load so it only happens
once.
Finally, here's a "source code only" container control that has the "disable
all controls inside when the container is disabled" behavior built in.
Super Container
http://www.vbsight.com/Code.htm
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
| |
| Mavrick 2006-02-01, 7:09 pm |
|
YAY thanks guys, this works
fraAppeals is the name of my frame, works a treat and not complex in
the slightest !
Sub SetFieldsOnOff(blnSetting As Boolean)
Dim k1 As Control
For Each k1 In Me.Controls
If k1.Container.Name = "fraAppeals" And TypeName(k1) <> "Label"
Then k1.Enabled = blnSetting
Next k1
End Sub
|
|
|
|
|