------解决方案-------------------- 根据一行生成TextBox:
string line3 = "a,b,c,d";
var fields = line3.Split(',');
var panel = new FlowLayoutPanel();
foreach (string s in fields)
{
var tb = new TextBox() {Text = s};
panel.Controls.Add(tb);
}
this.Controls.Add(panel);
------解决方案-------------------- var panel = Controls.Cast<Control>().First(c => c is FlowLayoutPanel);
var fields = panel.Controls.OfType<TextBox>().Select(c => c.Text);
string line3 = string.Join(",", fields);
lines[2] = "xxxx"; // 修改第三行
File.WriteAllText("c:/in.aaa", string.Join(" ", lines));