如何一次启用表单中的所有文本框?

问题描述:

如何一次对表单中的所有文本框启用false?

How to enable false to all the text boxes in the form at a time ?

尝试此操作...
Try this...
foreach(Control c in Controls)
{
   if(c is TextBox)
   {
      c.Enabled = true;
   }
}


在这种情况下,我要做的就是将控件放到面板上,当我需要禁用它们时,我以这种方式禁用了面板的所有子项.这样,您可以在不同面板上创建控件组,并且可以分别启用/禁用它们.这是我一直使用的解决方案.
What I do in such situations is that I put the controls to a panel and when I need to disable them I disable the panel this way all of its children are disabled. This way you can create groups of controls on different panels and you can enable/disable them individually. This is a solution I always use.