Quick way to reference ALL controls on form?

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

I want to disable all controls on form barring two buttons. I have
about 20 controls.
Is there a way I can reference all controls on the form in one go?

So I could then do something like..

AllControls.Enabled = false;
mybuttoncontrol.enabled = true;

Otherwise I have to write out manually every single control to disable.


Thanks,

Gary.
 
you can enumerate the Controls collection, noting that you then need
to look at their sub-controls and so-on; but the problem is knowing
which to re-enable afterwards...

Marc
 
Hi Mark,

Actually, iterating the Controls collection is all that is required since
sub-controls will inherit their parent's Enabled property value when it's
false.
 
Back
Top