C# 遍历控件名称
List<string> list = new List<string>(); list.Add("textBox2"); list.Add("textBox1"); list.Add("txtNum"); StringBuilder sb = new StringBuilder(); foreach (Control ctl in this.Controls) { if (ctl is TextBox) { //txtNum var obj = ctl.Name; sb.AppendFormat("list.Add(\"{0}\");",obj); } } var name = sb.ToString();