在我的MDIparent中,我将一些控件设置为enabled = false。我将如何启用所有控件,包括工具条项目,menustrip项目,menustrip子项目?
这是工作代码:
public void EnableAllControls(Control.ControlCollection Controls)
{
foreach (Control c in Controls)
{
c.Enabled = true;
if (c is MenuStrip)
{
foreach (ToolStripMenuItem item in ((MenuStrip)c).Items)
{
foreach (ToolStripItem e in item.DropDownItems)
e.Enabled = true;
item.Enabled = true;
}
}
if (c.HasChildren)
enableControls(c.Controls);
if (c is ToolStrip)
{
foreach (ToolStripItem item in ((ToolStrip)c).Items)
{
item.Enabled = true;
}
}
}
}