摘要:調整或清空panel所有控制項
foreach (object ctl in Panel1.Controls)
{
if (ctl.GetType() == typeof(TextBox))
{
TextBox txt = (TextBox)ctl;
txt.Text = "";
}
}
private void clean_pnl(ControlCollection pnlCon) //panel.Controls
{
//清空PANEL控制項的輸入值
foreach (object ctl in pnlCon)
{
if (ctl.GetType() == typeof(TextBox))
{
TextBox txt = (TextBox)ctl;
txt.Text = "";
}
if (ctl.GetType() == typeof(RadioButton))
{
RadioButton rb = (RadioButton)ctl;
rb.Checked = false;
}
if (ctl.GetType() == typeof(DropDownList))
{
DropDownList ddl = (DropDownList)ctl;
ddl.SelectedIndex = 0;
}
if (ctl.GetType() == typeof(RadioButtonList))
{
RadioButtonList rbl = (RadioButtonList)ctl;
rbl.SelectedIndex = -1;
}
if (ctl.GetType() == typeof(CheckBox))
{
CheckBox cb = (CheckBox)ctl;
cb.Checked = false;
}
}
}