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

C# win forms: How to disable all buttons in a form except few using a single method?

P: 40
hi all
can any one help me how to disable all buttons in a form except few using a method.

I coded to disable all buttons as:

Expand|Select|Wrap|Line Numbers
  1. private void disable_buttons()
  2.         {
  3.             foreach (Control ctrl in this.Controls)
  4.             {
  5.                 if (ctrl.GetType() == typeof(Button))
  6.                 {
  7.                     ctrl.Enabled = false;
  8.                 }
  9.             }
  10.  
  11.         }
  12.  
but when called from same class load event it doesnt works?
pls suggest me for this problem?
Expand|Select|Wrap|Line Numbers
  1. private void UserMaster_Load(object sender, EventArgs e)
  2.         {
  3.              disable_buttons();
  4.        }
  5.  
thank u

kssk
Dec 18 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.