Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to disable all controls with TAG property = 'X'
Message
 
To
16/05/2002 15:54:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00657662
Message ID:
00658273
Views:
25
Hi,

For containers, you would need to drill down the list of objects that
the container has. And since different container types are different,
you need a separate loop to do it, probably even a recursive loop.


** Procedure DisableControls
IF PARAMETERS() = 0
m.oControlParent = THISFORM
ELSE
m.oControlParent = m.oContainer
ENDIF

DO CASE
CASE ATC("Pageframe",m.oControlParent.BaseClass)#0
nCtrlCount = oControlParent.PageCount
CASE ATC(m.oControlParent.BaseClass,"Optiongroup,Commandgroup")#0
nCtrlCount = oControlParent.ButtonCount
OTHERWISE
nCtrlCount = oControlParent.ControlCount
ENDCASE

FOR i = 1 TO m.nCtrlCount
DO CASE
CASE ATC("Pageframe", m.oControlParent.BaseClass)#0
THIS.DisableControls(m.oControlParent.Pages[m.i])

CASE ATC(m.oControlParent.Controls[m.i].BaseClass, ;
"Optiongroup, Commandgroup")#0
THIS.DisableControls(m.oControlParent.Controls[m.i])

CASE ATC("Container",m.oControlParent.Controls[m.i].BaseClass) # 0 OR ;
ATC("Page",m.oControlParent.Controls[m.i].BaseClass) # 0
THIS.DisableControls(m.oControlParent.Controls[m.i])

OTHERWISE
IF m.oControlParent.Buttons[m.i].TAG = "X"
m.oControlParent.Buttons[m.i].Enabled = .F.
ENDIF

ENDCASE
ENDFOR


I haven't tested the above, but it is very similar to the one we are currently using in our system

HTH,
Arriyel

>The FOR EACH loControl routine works well only for 1st level controls. Nested controls are not tested. I have lots of nested controls (inside a pageframe, inside a container, etc). THe SETALL() function looks promising since it sees all controls regardless of nesting. But how do you set it so that it only set the control to be disabled when control.TAG='X'?
>SETALL('enabled',.f.) will disable all controls, not just the ones with .TAG='X'. ??? Thank you!!!
>
>
>>Hi,
>>
>>Try this in a method:
>>

>>For Each loControl in ThisForm.Controls
>> IF loControl.TAG = "X"
>> loControl.Enabled = .F.
>> ENDIF
>>ENDFOR
>>

>>
>>OR
>>
>>

>>ThisForm.SetAll('Enabled', .F.)
>>

>>
>>HTH,
>>Arriyel
>>
>>>I'd like to disable all controls in a form if its tag property = 'X'. Is there an easy way to do this? Thank you all!
Speak using soft and sweet words in case you have to eat them later.
Previous
Reply
Map
View

Click here to load this message in the networking platform