foreach (Control c in this.Controls)//遍历所有的控件 { if (c is TextBox) //如果是TextBox { TextBox txt = c as TextBox;//装换成TextBox txt.Text = "hello world"; } }