文本框是否为空的验证
private void CheckTextboxNotEmpty(ref bool isOK,params TextBox[] textboxes)
{
foreach(TextBox txtBox in textboxes)
{
if(txtBox.Text.Length<=0)
{
isOK=false;
txtBox.Background=Brushes.Red;
}
else
{
txtBox.Background=null;
}
}
}
下拉框是否选择验证
private void CheckComboBoxNotEmpty(ref bool isOK, params ComboBox[] cmbs)
{
foreach(ComboxBox cmb in cmbs)
{
if(cmb.SelectedIndex<0)
{
isOK=false;
cmb.Effect=new DropShadowEffect{Color=Colors.Red};
}
else
{
cmb. Effect =null;
}
}
}
CheckTextboxNotEmpty(
ref isOK,txtName,txtNational,txtNativeAddr,txtAddr);