2014-10-28 49 views

回答

0

比方说你保存文本框的名称和标签进入名单

List<string> labels = new List<string>(); 
List<string> textboxes = new List<string>(); 

然后你只需通过他们itterate,创建控件,并把它们的形式是这样的:

for(int a = 0; a< label.count;a++){ 

    Label l = new Label(); 
    l.Location = new Point(5,5+a*20); 
    l.Text = label[a]; 
    this.Controls.Add(l); 
} 

for(int a = 0; a< textboxes.count;a++){ 

    TextBox t = new TextBox(); 
    tl.Location = new Point(100,5+a*20); 
    t.Text = textboxes[a]; 
    this.Controls.Add(t); 
} 
相关问题