foreach(Control con in this.Controls[1].Controls)你现在的容器是Form!你确定没有讲这些控件放到其他的容器里面!你可以使用hasControl来递归的调用这个方法,可以实现将Form里面的所有的TextBox清空!代码我就不写了很简单,只要一个ControlCollection参数就可以实现!
这么说吧 先定位到你的用户控件再找到你的textbox再清空他
也可以 string mytext; foreach(Control co in this.Controls) { mytext=co.GetType().ToString(); if(mytext=="System.Windows.Forms.TextBox") ((TextBox)co).Text=""; }
确定你的容器
string mytext;
foreach(Control co in this.Controls)
{
mytext=co.GetType().ToString();
if(mytext=="System.Windows.Forms.TextBox")
((TextBox)co).Text="";
}
System.Windows.Forms.后面出不来TextBox
PTxt=(TextBox)con.FindControl("PointTxt");PTxt.Text="";