为什么要在如下方法中再调用一下showEnable(c)方法才会实现使所有控件不可修改的效果?
private void showEnable(Control ctrl)
{
this.cmdDelete.Enabled = true;
this.cmdSearch.Enabled = false;
this.cmdUpdate.Enabled = true;
this.cmdSave.Enabled = true;
foreach (Control c in ctrl.Controls)
{
if (c is DropDownList)
{
((DropDownList)c).Enabled = false;
((DropDownList)c).CssClass = "TextBoxReadOnly";
}
if (c is TextBox)
{
((TextBox)(c)).Enabled = false;
((TextBox)c).CssClass = "TextBoxReadOnly";
}
if (c is CheckBox)
{
((CheckBox)(c)).Enabled = false;
((CheckBox)c).CssClass = "TextBoxReadOnly";
}
showEnable(c);
}
}