没明白你的意思,不过你可以遍历窗体的Controls
foreach(Control obj in this.Controls)
{
if(obj.GetType()==typeof(TextBox))
{
((TextBox)obj).Value=...
}
}
foreach(Control obj in this.Controls)
{
if(obj.GetType()==typeof(TextBox))
{
((TextBox)obj).Value=...
}
}
调试欢乐多
http://www.c-sharpcorner.com/Code/2002/April/LoadingAssemblyInfo.asp
使用反射生成一个窗体:
private void button1_Click(object sender, System.EventArgs e)
{
Assembly assm = Assembly.LoadFrom("e:\\WindowsApplication5.dll");
Type TypeToLoad= assm.GetType("WindowsApplication5.Form1");
object obj;
obj = Activator.CreateInstance(TypeToLoad);
Form formToShow = null;
formToShow = (Form)obj;
formToShow.Show();
}
for (int i=1;i<=100;i++)
{
("a"+i).value="1";
}("a"+i)是个控件的名字,但是现在不好直接这样调用,要用个什么方法?
Assembly assembly = Assembly.LoadFrom(assemblyName);
Type formType = assembly.GetType(objectName);
MethodInfo method;
Form instance = (Form)Activator.CreateInstance(type);
if ((this.IsMdiContainer) && (instance.FormBorderStyle != FormBorderStyle.FixedDialog)) {
method = type.GetMethod(methodName, new Type[] {});
instance.MdiParent = this;
method.Invoke(instance, new object[]{});
} else {
method = type.GetMethod(methodName, new Type[] {typeof(Form)});
method.Invoke(instance, new object[]{this});
}
}
catch {
}
for (int i=1;i<=100;i++)
{
object obj=this.GetType().GetField("a"+i).GetValue(this);
if (obj !=null)
{
TextBox txt=obj as TextBox;
txt.value="1";
}
}
HtmlInputText text1 =(HtmlInputText)(Table2.Rows[0].Cells[0].Controls[0]);
Response.Write(text1.Value);