Quick way to reference ALL controls on form?

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.
 
M

Marc Gravell

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
 
D

Dave Sexton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top