环境:Net2.0
调用时直接Utility.ChangeChildEditMode(this.Form, false);
public static void ChangeChildEditMode(Control con, bool blnEditMode)
{
int i = 0;
foreach (Control c in con.Controls)
{
if (c is TextBox)
{
((TextBox)c).Enabled = blnEditMode;
}
else if (c is Button)
{
((Button)c).Enabled = blnEditMode;
}
else if (c is DropDownList)
{
((DropDownList)c).Enabled = blnEditMode;
}
else if (c is ListBox)
{
((ListBox)c).Enabled = blnEditMode;
}
else if (c is CheckBox)
{
((CheckBox)c).Enabled = blnEditMode;
}
else if (c is CheckBoxList)
{
((CheckBoxList)c).Enabled = blnEditMode;
}
else if (c is RadioButton)
{
((RadioButton)c).Enabled = blnEditMode;
}
else if (c is RadioButtonList)
{
((RadioButtonList)c).Enabled = blnEditMode;
}
else if (c is HyperLink)
{
((HyperLink)c).Enabled = blnEditMode;
}
else if (c.HasControls())
{
ChangeChildEditMode(c, blnEditMode);
i++;
}
}
}
{
int i = 0;
foreach (Control c in con.Controls)
{
if (c is TextBox)
{
((TextBox)c).Enabled = blnEditMode;
}
else if (c is Button)
{
((Button)c).Enabled = blnEditMode;
}
else if (c is DropDownList)
{
((DropDownList)c).Enabled = blnEditMode;
}
else if (c is ListBox)
{
((ListBox)c).Enabled = blnEditMode;
}
else if (c is CheckBox)
{
((CheckBox)c).Enabled = blnEditMode;
}
else if (c is CheckBoxList)
{
((CheckBoxList)c).Enabled = blnEditMode;
}
else if (c is RadioButton)
{
((RadioButton)c).Enabled = blnEditMode;
}
else if (c is RadioButtonList)
{
((RadioButtonList)c).Enabled = blnEditMode;
}
else if (c is HyperLink)
{
((HyperLink)c).Enabled = blnEditMode;
}
else if (c.HasControls())
{
ChangeChildEditMode(c, blnEditMode);
i++;
}
}
}