foreach(TextBox tb in.....
具体该如何写,肯请指点
具体该如何写,肯请指点
解决方案 »
- 在datagrid中依次显示数据库中数据,每次显示十条
- 求如何在ASP.net中使用FTP类直接读取FTP路径下的xml文件内容
- 急!读取文本
- 在类中使用了非托管资源(比如GDI+的东西),而没有实现finalize也没有实现dispose,那这些非托管资源将会如何被处理?
- 数组的维数能用变量声明吗?
- 关于Window Form
- 请问高手们:我要把GRID中修改的数据保存到SQLSERVER服务器上去,应该怎么做呀?
- 数组取平均值的问题
- C#中StringBuilder的问题。
- rdlc打印的问题 求解。。。。
- 请教IList,HashTable,IDirectiroy,SortedList等相互之间有什么区别?
- 求助!急急急!如何用C#写随机生成24位数字的程序!小弟摆脱各位大侠了!
{
if (this.Controls[i] is TextBox)
{
(this.Controls[i] as TextBox).Text = "";
}
}
请问这个是不是C#的啊?
{
if (ctl is TextBox)
{
ctl.Text = string.Empty;
}
}
If TypeOf(objButton) is textBox Then
objButton.Text = ""
End If
Next
{
if (container == null ) return ;
if (container is TextBox )
{
container.text="";
return;
}
if (container.Controls.Count > 0 )
{
for (int i=0; i < container.Controls.Count; i++)
{
settextbox(container.Controls[i]);
}
}
}
{
if (control is TextBox)
{
ctl.Text = "";
}
}
string ControlType;
foreach (Control Ctl in this.Controls)
{
ControlType=Ctl.GetType().ToString();
if (ControlType=="System.Windows.Forms.TextBox")
((TextBox)Ctl).Text="";
}
其中:this代表包含文本框的容器。
控件里的TextBox?
控件里的TextBox?因为不仅form可以包含textbox,form里面的groupbox,panel也可能包含textbox.
foreach (Control Ctl in this.Controls)
{
TextBox t = Ctrl as TextBox;
if(t != null)
{
t.Text = "";
}
}
这样写的效率要高一些.
{
if (Ctl is TextBox)
{
(TextBox)Ctl.Text = "";
}
}
for (int i = 0; i < nControls; i++)
{
foreach (System.Web.UI.Control control in this.Controls[i].Controls )
{
if (control is TextBox)
(control as TextBox).Text = "";
}
}
{
if(cl.GetType().ToString()=="System.Web.UI.WebControls.TextBox")
{
((TextBox)cl).Text="";
}
}
它只能查找不能副值
所以你只能使用for
后其他的
for(int i=0;i<n;i++)
textBoxi.Text=null;
这样就行了