这样如何?
foreach( Control c in this.Controls)
{
if(c.GetType().ToString()=="System.Windows.Forms.TextBox")
{
c.Text="";
}
}
foreach( Control c in this.Controls)
{
if(c.GetType().ToString()=="System.Windows.Forms.TextBox")
{
c.Text="";
}
}
TextBox1.Text = TextBox2.Text = TextBox3.Text = ... = "";可能把所有的TextBox加到一个数组会做更多的事情:)---- 个人意见
if(o.GetType().Name=="TextBox")
{
if(((TextBox)o).ReadOnly==false&&((TextBox)o).Enabled==true && ((TextBox)o).Visible == true)
{
((TextBox)o).Text="";
}
}
if(o.GetType().Name=="DropDownList")
{
if (((DropDownList)o).Enabled==true && ((DropDownList)o).Visible == true)
{
((DropDownList)o).SelectedIndex=0;
}
}
if(o.Controls.Count>0)
{
clearForm(o);
}
的方法在TextBox控件占整个窗体的子控件的
比例很大的话确实很值得用:)
就是vs.net搜索控件的顺序是什么?
如果一些控件在groupbox上,是不是还要写代码继续判断是不是在groupbox里面?我之所以这么问是因为我遇到了类似的问题,控件在某个容器里面,像上面这样的代码就会忽略容器里面的控件。请顺便解决一下,谢谢。