111,126
社区成员
发帖
与我相关
我的任务
分享
protected void Condition()
{
foreach (Control c in this.FindControl("form1").Controls)
{
if (c is TextBox)
{
((TextBox)c).Text = "";
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Condition();
}
//设置界面上控件的Enable为false,并且设置TextBox的边框样式
public static void SetChildControlsReadOnlyPropertyAndBorderStyle(Control parentControl, bool isReadOnly ) {
int i;
DropDownList tempDropDownList;
TextBox tempTextBox;
CheckBox tempCheckBox;
if (parentControl == null) return;
for (i = 0; i < parentControl.Controls.Count; i++)
{
if (parentControl.Controls[i].GetType().Name == "TextBox")
{
tempTextBox = (TextBox)parentControl.Controls[i];
tempTextBox.ReadOnly = isReadOnly;
tempTextBox.ForeColor = Color.Black;
}
if (parentControl.Controls[i].GetType().Name == "DropDownList")
{
tempDropDownList = (DropDownList)parentControl.Controls[i];
tempDropDownList.Enabled = !isReadOnly;
}
if (parentControl.Controls[i].GetType().Name == "CheckBox")
{
tempCheckBox = (CheckBox)parentControl.Controls[i];
tempCheckBox.Enabled = !isReadOnly;
}
}
}((TextBox)this.Controls[1].Controls[i]).Text = string.Empty ;
protected void Condition()
{
foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)control;
tb.Text = "";
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Condition(this);
} foreach (Control Ctrol in this.Controls)
{
if (Ctrol is TextBox)
{
Ctrol.Text = "";
}
} foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)control;
tb.Text = "";
}
}