1 foreach(Control c in this.Controls) 2 { 3 if (c is TextBox) 4 { 5 if (string.IsNullOrEmpty((c as TextBox).Text)) 6 { 7 MessageBox.Show("请正确填写内容,带*为必填内容"); 8 return; 9 } 10 } 11 }