请编程遍历页面上所有TextBox控件并给它赋值为string.Empty?
正确答案:
foreach(System.Windows.Forms.Controlcontrolinthis.Controls)
{
if(controlisSystem.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBoxtb=(System.Windows.Forms.TextBox)control;
tb.Text=String.Empty;
}
}
{
if(controlisSystem.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBoxtb=(System.Windows.Forms.TextBox)control;
tb.Text=String.Empty;
}
}
答案解析:有
微信扫一扫手机做题