1、首先你的的textbox不是在this.Controls下,而是其中的HtmlForm.Controls下。2、如果你的textbox的父容器是在panel控件下,你也只能通过panel.Controls来访问,
解决方案 »
- iis无法访问网站
- Environment.UserName和WindowsIdentity.GetCurrent().Name区别
- c# 调用 shutdown问题
- string转换成xml问题。
- 菜鸟寻求高手帮忙????迫在眉睫!!!!!
- 单点登录怎么做
- 一个奇怪的问题PictureBox
- 能用查询DataSet里面的数据吗?
- 在窗体onpaint事件触发后,什么事件触发画窗体上的控件?
- 在菜单中......e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height各代表什么?多谢!!
- 在dataGrid中,如何禁止用户自己添加新行?而且我要能修改列,且只能通过我的程序来增加新列
- 问一个关于C#的问题
------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
Reset(this.Controls);
}private void Reset(ControlCollection ctls)
{
foreach(Control ctl in ctls)
{
if(ctl is TextBox)
{
TextBox tb=(TextBox) ctl;
tb.Text="0";
}
if(ctl.Controls.Count!=0)
Reset(ctl.Controls);
}
}
{
if (control.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
((TextBox)control).Text="0";
}
}
厉害,不错,学习一把。感谢楼主~~~~~
我是这样写的.
ControlCollection ctls;
foreach(Control ctl in ctls)
{
if(ctl is TextBox) {
TextBox tb=(TextBox)ctl;
tb.Text="";
}
}
{
foreach(Control c in cc)
{
if (c is TextBox )
{
}
//Are there further Controls inside current Control?
if (c.HasControls())
{
CollectControls(c.Controls);
}
}
}
把我给你写的FORM1换成你表单(FORM)的ID就可以了。