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();
- 上一篇 »C# 遍历对象的属性 获取或设置值
- 下一篇 »c# 遍历类中的方法名称