By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,286 Members | 2,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,286 IT Pros & Developers. It's quick & easy.

Quick way to reference ALL controls on form?

P: n/a
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.

Jan 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Jan 5 '07 #2

P: n/a
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.

--
Dave Sexton
http://davesexton.com/blog

"Marc Gravell" <ma**********@gmail.comwrote in message
news:eh**************@TK2MSFTNGP02.phx.gbl...
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

Jan 5 '07 #3

P: n/a
True... true... forgot that nuance ;-p

Marc
Jan 5 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.