foreach (Control item in this.groupBox2.Controls) { if (item is TextBox) { if (item.Text.Trim() == "") { MessageBox.Show("文本框不能为空!", "提示"); return; } } }