Skip to main content
added 16 characters in body
Source Link
Sergey Berezovskiy
  • 237k
  • 44
  • 441
  • 468

You can enumerate controls and disable them:

foreach(var control in Controls.Cast<Control>()) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

Or if you have some other criteria of selection

var controlsToDisable = Controls.OfType<TextBox>() .Where(t => t.Name.StartsWith("Control")); // etc foreach(var control in controlsToDisable) control.Enabled = false; 

You can enumerate controls and disable them:

foreach(var control in Controls) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

Or if you have some other criteria of selection

var controlsToDisable = Controls.OfType<TextBox>() .Where(t => t.Name.StartsWith("Control")); // etc foreach(var control in controlsToDisable) control.Enabled = false; 

You can enumerate controls and disable them:

foreach(var control in Controls.Cast<Control>()) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

Or if you have some other criteria of selection

var controlsToDisable = Controls.OfType<TextBox>() .Where(t => t.Name.StartsWith("Control")); // etc foreach(var control in controlsToDisable) control.Enabled = false; 
added 255 characters in body
Source Link
Sergey Berezovskiy
  • 237k
  • 44
  • 441
  • 468

You can enumerate controls and disable them:

foreach(var control in Controls) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

Or if you have some other criteria of selection

var controlsToDisable = Controls.OfType<TextBox>() .Where(t => t.Name.StartsWith("Control")); // etc foreach(var control in controlsToDisable) control.Enabled = false; 

You can enumerate controls and disable them:

foreach(var control in Controls) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

You can enumerate controls and disable them:

foreach(var control in Controls) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false; 

Or if you have some other criteria of selection

var controlsToDisable = Controls.OfType<TextBox>() .Where(t => t.Name.StartsWith("Control")); // etc foreach(var control in controlsToDisable) control.Enabled = false; 
Source Link
Sergey Berezovskiy
  • 237k
  • 44
  • 441
  • 468

You can enumerate controls and disable them:

foreach(var control in Controls) control.Enabled = false; 

If you want to disable only buttons, you can use LINQ

foreach(var control in Controls.OfType<Button>()) control.Enabled = false;