2014-10-28 42 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); 
} 
相關問題