The problem is that your validation method returns only the last result - if the final combobox in the list is not empty, it will return false.
Try
break
on failure, or
return
BTW: Did you know you can do the test a lot easier and more accurately?
public bool val2()
{
foreach (Control item in panel1.Controls.OfType<ComboBox>())
{
if (string.IsNullOrWhiteSpace(item.Text))
{
return true;
}
}
return false
}
Oh, and
tat
should not be a class level variable - if you are going to do it your way,
tat
should be local to the method, not declared outside it.