winform 组件简单遍历判断
foreach (Control item in this.Controls)
{
if (item is TextBox)
{
if (item.Text.Length <= 0)
{
TextBox t = (TextBox)item;
t.Focus();
t.BackColor = Color.Red;
MessageBox.Show("该项不能为空!");
return;
}
}
}

浙公网安备 33010602011771号