我还是不看不太懂我现在使用程序生成了 textbox_1,textbox_2,textbox_3,textbox_4我可不可以通过一个循环取出每一个 textbox_n 的 text 呢?比方说 for (int i=1;i<=4;i++) { lable1.text=lable1.text + ";" + textbox_i.text }但是很显然,花括号里面的语句是不正确的 我想只知道怎样实现这个过程呢谢谢
.NET is strongly typed, do not expect things like eval which are usually associated with scripting languages to be applicable in .NETtryfor (int i=0; i < FormID.Controls.Count; i++) { if (FormID.Controls[i] is TextBox) { Label1.Text += ";" + ((TextBox)FormID.Controls[i]).Text } }
就怎么简单????????昏.............几乎所有的人都认为你问的是动态创建问题 string[] strArray=new string[3]; int i=0; foreach(Control c in this.Controls) { if(c.GetType()=="System.web.ui.webcontrol.textbox") strArray[i]=(TextBox)c).Text; i++; } foreach(Control c in this.Controls) { if(c.GetType()=="System.web.ui.webcontrol.lable") ((lable)c).text=strArray[i]; i++; }
string strClass;
Assembly asm = Assembly.LoadFrom(strFileName);
oClass = asm.CreateInstance(strClass);
tType = asm.GetType(strClass);
{
lable1.text=lable1.text + ";" + textbox_i.text
}但是很显然,花括号里面的语句是不正确的
我想只知道怎样实现这个过程呢谢谢
{
if (FormID.Controls[i] is TextBox)
{
Label1.Text += ";" + ((TextBox)FormID.Controls[i]).Text
}
}
string[] strArray=new string[3];
int i=0;
foreach(Control c in this.Controls)
{
if(c.GetType()=="System.web.ui.webcontrol.textbox")
strArray[i]=(TextBox)c).Text;
i++;
}
foreach(Control c in this.Controls)
{
if(c.GetType()=="System.web.ui.webcontrol.lable")
((lable)c).text=strArray[i];
i++;
}