|
-
Feb 21st, 2003, 03:47 PM
#1
Thread Starter
PowerPoster
VB Snippet - Enable all Controls within a Frame Control
VB Code:
Public Sub EnableFrame(InFrame As Frame, ByVal Flag As Boolean)
Dim Contrl As Control
On Error Resume Next 'not all controls have a container property
InFrame.Enabled = Flag
For Each Contrl In InFrame.Parent.Controls
If Contrl.Container.Name = InFrame.Name Then
If (TypeOf Contrl Is Frame) And Not (Contrl.Name = InFrame.Name) Then
EnableFrame Contrl, Flag 'repeat for nested frame
Else
Contrl.Enabled = Flag
End If
End If
Next
End Sub
Private Sub Command1_Click()
EnableFrame frame1,True
End Sub
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
May 15th, 2012, 04:57 AM
#2
Hyperactive Member
Re: VB Snippet - Enable all Controls within a Frame Control
hi, i m very sorry to say. but your code has a bug/error.. because as you used resume next, it also handle unwanted (not a child control of specific frame) that user may not want..
so, the following code only handle (disable/enable) the controls that parent is the frame.
Code:
Public Sub sEnableFrame(objFrame As Frame, ByVal bolFlag As Boolean)
On Error GoTo mahabub_S1Error
Dim objControl As Control
objFrame.Enabled = bolFlag
For Each objControl In Me.Controls
If objControl.Container.Name = objFrame.Name Then
If (TypeOf objControl Is Frame) Then
sEnableFrame objControl, bolFlag
Else
objControl.Enabled = bolFlag
End If
End If
mahabub_nextS1Loop:
Next objControl
Set objControl = Nothing
Exit Sub
mahabub_S1Error:
If Err.Number = 438 Then
Resume mahabub_nextS1Loop
Exit Sub
End If
End Sub
however thanks for the idea..
best regards
-
Oct 10th, 2016, 12:54 PM
#3
New Member
Re: VB Snippet - Enable all Controls within a Frame Control
Thanks @Shohag_ifas. Your alternate solution worked great on the app that I'm developing.
-
Oct 10th, 2016, 04:06 PM
#4
Re: VB Snippet - Enable all Controls within a Frame Control
What about a PictureBox on the frame with further nested control, or possibly an SSTab control on the frame. 
Here's one that works regardless of the type of container you're digging down into:
http://www.vbforums.com/showthread.p...=1#post5084349
Enjoy,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|